WatchdogLogger.php in Service Container 7
File
src/Logger/WatchdogLogger.php
View source
<?php
namespace Drupal\service_container\Logger;
use Drupal\service_container\Legacy\Drupal7;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
class WatchdogLogger extends LoggerBase implements LoggerInterface {
protected $drupal7;
public function __construct(Drupal7 $drupal7) {
$this->drupal7 = $drupal7;
}
public function log($level, $message, array $context = array()) {
$map = array(
LogLevel::EMERGENCY => WATCHDOG_EMERGENCY,
LogLevel::DEBUG => WATCHDOG_DEBUG,
LogLevel::INFO => WATCHDOG_INFO,
LogLevel::ALERT => WATCHDOG_ALERT,
LogLevel::CRITICAL => WATCHDOG_CRITICAL,
LogLevel::ERROR => WATCHDOG_ERROR,
LogLevel::NOTICE => WATCHDOG_NOTICE,
);
$watchdog_level = $map[$level];
$type = isset($context['channel']) ? $context['channel'] : 'default';
unset($context['channel']);
$this->drupal7
->watchdog($type, $message, $context, $watchdog_level);
}
}