Skip to content

Instantly share code, notes, and snippets.

@mondalaci
Created April 3, 2013 21:54
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 mondalaci/5305788 to your computer and use it in GitHub Desktop.
Save mondalaci/5305788 to your computer and use it in GitHub Desktop.
Prepend datestamps to lines coming from stdin
#!/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