public LoggerChannel::log($level, $message, array $context = array())
Logs with an arbitrary level.
mixed $level:
string $message:
array $context:
null
Overrides LoggerTrait::log
public function log($level, $message, array $context = array()) { if ($this->callDepth == self::MAX_CALL_DEPTH) { return; } $this->callDepth++; // Merge in defaults. $context += array( 'channel' => $this->channel, 'link' => '', 'user' => NULL, 'uid' => 0, 'request_uri' => '', 'referer' => '', 'ip' => '', 'timestamp' => time(), ); // Some context values are only available when in a request context. if ($this->requestStack && $request = $this->requestStack->getCurrentRequest()) { $context['request_uri'] = $request->getUri(); $context['referer'] = $request->headers->get('Referer', ''); $context['ip'] = $request->getClientIP(); try { if ($this->currentUser) { $context['user'] = $this->currentUser; $context['uid'] = $this->currentUser->id(); } } catch (\Exception $e) { // An exception might be thrown if the database connection is not // available or due to another unexpected reason. It is more important // to log the error that we already have so any additional exceptions // are ignored. } } if (is_string($level)) { // Convert to integer equivalent for consistency with RFC 5424. $level = $this->levelTranslation[$level]; } // Call all available loggers. foreach ($this->sortLoggers() as $logger) { $logger->log($level, $message, $context); } $this->callDepth--; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Logger!LoggerChannel.php/function/LoggerChannel::log/8.1.x