Advertisement
nezzario

CLI Retro Logging

Jun 25th, 2014
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. <?php
  2. function ob_logstdout($chunk, $phase) {
  3. $msec = substr(explode(' ', microtime())[0], 2, 4);
  4. $return_chunk = '';
  5. if(substr($chunk, -1) == "\n") {
  6. $chunk = substr($chunk, 0, -1);
  7. }
  8. $lines = explode("\n", $chunk);
  9. foreach($lines as $line) {
  10. $line = date('[m-d-y h:i:s.') . $msec . date(' A] ') . $line . "\n";
  11. file_put_contents(ROOTDIR . '/data/scraper-lastlog', $line, FILE_APPEND);
  12. $return_chunk .= $line;
  13. }
  14. return $return_chunk;
  15. }
  16. ob_start('ob_logstdout', 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement