Advertisement
Guest User

Untitled

a guest
Jul 17th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.53 KB | None | 0 0
  1. public static function createLog($cpa = null, $error = null)
  2.     {
  3.         $appDir = \Yii::getAlias('@app');
  4.         $path = $appDir . '/logs';
  5.         $filePath = $path .'/cpa_cron_log' . '.txt';
  6.         if(!file_exists($path)){
  7.             mkdir($path,0666);
  8.         }
  9.         $time = new \DateTime();
  10.         $currentTime = $time->format('Y-m-d H:i:s');
  11.         $log = PHP_EOL . $currentTime . PHP_EOL . $cpa . PHP_EOL . 'error_info: ' . $error . PHP_EOL;
  12.         file_put_contents($filePath, $log, FILE_APPEND | LOCK_EX);
  13.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement