Example #1
0
 /**
  * ログ出力
  */
 public function __call($name, $args)
 {
     if (false !== ($level = LogLevel::toInt($name))) {
         $this->post(Log::create(isset($args[0]) ? $args[0] : 'no message', isset($args[1]) ? $args[1] : [], $level, isset($args[2]) ? $args[2] : null));
         return true;
     }
     throw new Exception\InvalidMethod($name, $this);
 }
Example #2
0
 /**
  * ロガーの登録
  *
  * @depends testLoadModule
  */
 public function testLogger($module)
 {
     $logger = $module->getLogger();
     $logger->post(Log::create('ログテスト(INFO)', ['method' => __METHOD__], LogLevel::INFO, 'tag1'));
     $logger->emerg("MESSAGE");
     $logger->alert("MESSAGE");
     $logger->crit("MESSAGE");
     $logger->err("MESSAGE");
     $logger->warning("MESSAGE");
     $logger->notice("MESSAGE");
     $logger->info("MESSAGE");
     $logger->debug("MESSAGE");
     $logger->debug("テスト", ['file' => __FILE__, 'line' => __LINE__], ['phpunit', 'nora']);
     $module->register();
     trigger_error('hoge');
     trigger_error('hoge', E_USER_ERROR);
 }
Example #3
0
 /**
  * ログを整形する
  *
  * @param Log $log
  * @return string
  */
 public function format(Log $log)
 {
     return vsprintf($this->_compiled_format, ['[' . $log->getTag() . ']', $log->getMsg(), LogLevel::toString($log->getLevel()), json_encode($log->getArgs(), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE), date($this->_date_format, $log->getTime())]);
 }
Example #4
0
 public function write(Log $log)
 {
     if ($log->getLevel() <= $this->_level) {
         $this->writeImpl($log);
     }
 }