Posted By

MikeDevDes on 10/12/12


Tagged

log


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

knedle


Simple logger function


 / Published in: PHP
 

Simple logger function

  1. function log( $logthis ){
  2. file_put_contents('logfile.log', date("Y-m-d H:i:s"). " " . $logthis. "\r\n", FILE_APPEND | LOCK_EX);
  3. }
  4.  
  5. // use \r\n for new line on windows, just \n on linux
  6. // PHP_EOL cross platform solution for new line
  7. // // so better to use this
  8.  
  9. function log( $logthis ){
  10. file_put_contents('logfile.log', date("Y-m-d H:i:s"). " " . $logthis.PHP_EOL, FILE_APPEND | LOCK_EX);
  11. }

Report this snippet  

You need to login to post a comment.