Пример #1
0
 public function testServerValues()
 {
     $_SERVER['SERVER_ADDR'] = 'foo';
     $this->config->setServerValues(['SERVER_ADDR']);
     $values = $this->config->getServerValues();
     $this->assertArrayHasKey('SERVER_ADDR', $values);
     $this->assertEquals('foo', $values['SERVER_ADDR']);
 }
Пример #2
0
 /**
  * Send the log data to registered outputs
  *
  * @param $logLevel
  * @param $message
  * @param array $context
  * @throws \InvalidArgumentException
  * @return bool
  */
 protected function output($logLevel, $message, array $context = [])
 {
     if ($logLevel < $this->config->getLogLevel()) {
         return false;
     }
     $this->logData = ['app_id' => $this->config->getAppId(), 'channel' => $this->config->getChannel(), 'environment' => $this->config->getEnvironment(), 'message' => (string) $message, 'context' => empty($context) ? null : json_encode($context), 'log_level' => $logLevel, 'log_level_name' => $this->getLogLevelName($logLevel), 'extras' => $this->config->getExtraValues(), 'trace' => $this->backtrace->info(), 'created_at' => $this->config->getDateTimeFormatted()];
     foreach ($this->config->getOutputHandlers() as $v) {
         $v->send(json_encode($this->logData));
     }
     return true;
 }
Пример #3
0
 public function testOutputLevelIsLargerThanSubmittedOneAndReturnFalse()
 {
     $config = new Config();
     $config->setAppId('b85066fc-248f-4ea9-b13d-0858dbf4efc1')->setLogLevel(Logger::ERROR);
     $logger = new Logger($config);
     $result = $logger->info('test', ['test']);
     $this->assertFalse($result);
 }