-
-
Save RWJMurphy/4704592 to your computer and use it in GitHub Desktop.
Reads lines from stdin, appends a timestamp and prints to stdout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from __future__ import print_function | |
from datetime import datetime | |
import sys | |
def main(): | |
try: | |
while 1: | |
line = sys.stdin.readline() | |
if line == '': | |
break | |
print("{}\t{}".format(datetime.now().isoformat(), line), end="") | |
sys.stdout.flush() | |
except KeyboardInterrupt: | |
pass | |
return 0 | |
if __name__ == "__main__": | |
sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment