Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.64 KB | None | 0 0
  1. function logToFile($msg) {
  2.     $file = "../cron-log/wrikeSlackTaskIntegration.log";
  3.     if (filesize($file) < 2097152) {
  4.         // If file size more than 2Mb rename this file and create new
  5.         $dateTimePrague = new \DateTime('now', new \DateTimeZone('Europe/Prague'));
  6.         $startDay = file_get_contents($file, false, null, null, 10);
  7.         $newName = substr($file, 0, -4)."_".$startDay."_".$dateTimePrague->format('Y-m-d').".log";
  8.         rename($file, $newName);
  9.         $bla = fopen($file, "w");
  10.         fclose($bla);
  11.     }
  12.     $fd = fopen($file, "a");
  13.     fwrite($fd, $msg . "\n\n");
  14.     fclose($fd);
  15. }
  16.  
  17. logToFile('log message');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement