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

Report this snippet  

You need to login to post a comment.