Skip to content

Instantly share code, notes, and snippets.

@gkeramidas
Created January 11, 2024 23:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gkeramidas/8b048a28b97be28fa21ebbb90dea2153 to your computer and use it in GitHub Desktop.
Save gkeramidas/8b048a28b97be28fa21ebbb90dea2153 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import datetime
import sys
def timestamp():
now = datetime.datetime.now()
return (now.strftime('%Y-%m-%d %H:%M:%S.%m') +
".%06d" % now.microsecond)
if __name__ == '__main__':
try:
while True:
line = sys.stdin.readline()
if line == '':
break
line = line.rstrip('\n\r')
sys.stdout.write("%s -- %s\n" % (timestamp(), line))
sys.stdout.flush()
except KeyboardInterrupt:
sys.stderr.write('Interrupted')
sys.exit(1) # interrupted
except IOError:
sys.exit(74) # EX_IOERR from sysexits.h
except:
sys.exit(70) # EX_SOFTWARE from sysexits.h
sys.exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment