/** * 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; }
public function testSetChannel() { $this->assertEquals('php-test', $this->config->getChannel()); $this->config->setChannel('php-app-production'); $this->assertEquals('php-app-production', $this->config->getChannel()); }