Example #1
0
 public static function obHandler($output)
 {
     if (!self::$ob_skip) {
         $instance = new self(self::LOG_WARNING);
         $state = $instance->getState();
         $instance->current_stage = $state['stage_name'] . '_' . self::STATE_ERROR;
         $instance->current_chunk_id = $state['chunk_id'];
         $message = $output;
         if ($error = error_get_last()) {
             $message .= sprintf('%s @%s:%d', $error['message'], $error['file'], $error['line']);
         }
         $instance->writeLog(__METHOD__ . ' error : ' . $message, self::LOG_ERROR);
         $state = array_merge($state, array('error' => $message, 'stage_status' => self::STATE_ERROR));
         $instance->setState($state);
     }
     return $output;
 }
Example #2
0
 /**
  * write message to the log file. this is shorter static method.
  * 
  * @param string $channel name your channel.
  * @param string $log_level log level can be debug, info, notice, warning, error, critical, alert, emergency *(not recommend).
  * @param string $message the message that will be write to log file.
  * @param array $context some array such as ['username' => 'myusername'].
  * @return type
  */
 public static function write($channel, $log_level, $message, $context = [])
 {
     $this_class = new self($channel, $log_level);
     return $this_class->writeLog($message, $context);
 }
 public static function obHandler($output)
 {
     if (!self::$ob_skip) {
         $instance = new self(self::LOG_WARNING);
         $state = $instance->getState();
         $instance->current_stage = $state['stage_name'] . '_' . self::STATE_ERROR;
         $instance->current_chunk_id = $state['chunk_id'];
         $instance->writeLog(__METHOD__ . ' error: ' . strip_tags($output), self::LOG_ERROR);
         $state = array_merge($state, array('error' => strip_tags($output), 'stage_status' => self::STATE_ERROR));
         $instance->setState($state);
     }
     return $output;
 }