コード例 #1
0
ファイル: XConsoleCommand.php プロジェクト: hung5s/yap
 /**
  * Log the command was run into cron log table and email to DEV_EMAILS cron log result
  *
  * @param string $action
  * @param array  $params
  * @param int    $exitCode
  *
  * @return int|void
  */
 public function afterAction($action, $params, $exitCode = 0)
 {
     parent::afterAction($action, $params, $exitCode = 0);
     $commandName = $_SERVER['argv'][1];
     $params = json_encode($params);
     $serverName = gethostname();
     $model = new CronLog();
     $model->command_name = $commandName;
     $model->params = $params;
     $model->server_name = $serverName;
     $logFile = $this->getLogFile();
     $model->run_log = @file_get_contents($logFile);
     if ($this->emailLog) {
         $logs = "{$commandName} is run at " . date('m/d/Y h:i:s') . "\n";
         $logs .= 'Parameters: ' . print_r($_SERVER['argv'], 1) . "\n";
         $logs .= $this->getLogs();
         $logs .= print_r($_SERVER, 1);
         xmail($commandName . ' run log', nl2br($logs), SETTINGS_DEV_EMAILS);
     }
     @unlink($logFile);
     $model->save();
 }