Created
April 3, 2013 21:54
-
-
Save mondalaci/5305788 to your computer and use it in GitHub Desktop.
Prepend datestamps to lines coming from stdin
This file contains hidden or 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 php5 | |
<?php | |
# It's a dead-simple utility that prefixes lines with the current timestamp. | |
# With Bash it's supposed to be used something like this: | |
# yourcommand | timestamper | tee whatever.log | |
while (!feof(STDIN)) { | |
$line = trim(fgets(STDIN)); | |
print strftime('%Y-%m-%d %H:%M:%S ') . "$line\n"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment