class WatchdogLogger in Service Container 7
Same name and namespace in other branches
- 7.2 src/Logger/WatchdogLogger.php \Drupal\service_container\Logger\WatchdogLogger
Implements the PSR-3 logger with watchdog.
@codeCoverageIgnore
Hierarchy
- class \Drupal\service_container\Logger\LoggerBase implements LoggerInterface
- class \Drupal\service_container\Logger\WatchdogLogger implements LoggerInterface
Expanded class hierarchy of WatchdogLogger
1 file declares its use of WatchdogLogger
- WatchdogLoggerTest.php in tests/
src/ Logger/ WatchdogLoggerTest.php - Contains \Drupal\Tests\service_container\Logger\WatchdogLoggerTest.
File
- src/
Logger/ WatchdogLogger.php, line 19 - Contains \Drupal\service_container\Logger\WatchdogLogger.
Namespace
Drupal\service_container\LoggerView source
class WatchdogLogger extends LoggerBase implements LoggerInterface {
/**
* The Drupal7 service.
*
* @var \Drupal\service_container\Legacy\Drupal7
*/
protected $drupal7;
/**
* Constructs a WatchdogLogger object.
*
* @param \Drupal\service_container\Legacy\Drupal7 $drupal7
* The Drupal7 service.
*/
public function __construct(Drupal7 $drupal7) {
$this->drupal7 = $drupal7;
}
/**
* {@inheritdoc}
*/
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];
// Map the logger channel to the watchdog type.
$type = isset($context['channel']) ? $context['channel'] : 'default';
unset($context['channel']);
$this->drupal7
->watchdog($type, $message, $context, $watchdog_level);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LoggerBase:: |
public | function |
Action must be taken immediately. Overrides LoggerInterface:: |
|
LoggerBase:: |
public | function |
Critical conditions. Overrides LoggerInterface:: |
|
LoggerBase:: |
public | function |
Detailed debug information. Overrides LoggerInterface:: |
|
LoggerBase:: |
public | function |
System is unusable. Overrides LoggerInterface:: |
|
LoggerBase:: |
public | function |
Runtime errors that do not require immediate action but should typically
be logged and monitored. Overrides LoggerInterface:: |
|
LoggerBase:: |
public | function |
Interesting events. Overrides LoggerInterface:: |
|
LoggerBase:: |
public | function |
Normal but significant events. Overrides LoggerInterface:: |
|
LoggerBase:: |
public | function |
Exceptional occurrences that are not errors. Overrides LoggerInterface:: |
|
WatchdogLogger:: |
protected | property | The Drupal7 service. | |
WatchdogLogger:: |
public | function |
Logs with an arbitrary level. Overrides LoggerInterface:: |
|
WatchdogLogger:: |
public | function | Constructs a WatchdogLogger object. |