class Logger in Monolog 2.x
Same name and namespace in other branches
- 8 src/Logger/Logger.php \Drupal\monolog\Logger\Logger
Logger class for the Drupal Monolog module.
Allows the channel to be modified after the class is instantiated. This is normally not a good idea, but it is necessary to reconcile the differences in the Monolog library and how the watchdog type relates to the logging facility.
Hierarchy
- class \Drupal\monolog\Logger\Logger extends \Monolog\Logger implements LoggerChannelInterface
Expanded class hierarchy of Logger
1 file declares its use of Logger
- LoggerTest.php in tests/
src/ Unit/ Logger/ LoggerTest.php
File
- src/
Logger/ Logger.php, line 20
Namespace
Drupal\monolog\LoggerView source
class Logger extends BaseLogger implements LoggerChannelInterface {
/**
* Map of RFC 5424 log constants to Monolog log constants.
*
* @var array
*/
protected $levelTranslation = [
RfcLogLevel::EMERGENCY => MonologLogLevel::EMERGENCY,
RfcLogLevel::ALERT => MonologLogLevel::ALERT,
RfcLogLevel::CRITICAL => MonologLogLevel::CRITICAL,
RfcLogLevel::ERROR => MonologLogLevel::ERROR,
RfcLogLevel::WARNING => MonologLogLevel::WARNING,
RfcLogLevel::NOTICE => MonologLogLevel::NOTICE,
RfcLogLevel::INFO => MonologLogLevel::INFO,
RfcLogLevel::DEBUG => MonologLogLevel::DEBUG,
];
/**
* {@inheritdoc}
*/
public function addRecord($level, $message, array $context = []) : bool {
if (array_key_exists($level, $this->levelTranslation)) {
$level = $this->levelTranslation[$level];
}
return parent::addRecord($level, $message, $context);
}
/**
* {@inheritdoc}
*/
public function setRequestStack(RequestStack $requestStack = NULL) {
// Do nothing, use a handler for this.
}
/**
* {@inheritdoc}
*/
public function setCurrentUser(AccountInterface $current_user = NULL) {
// Do nothing, use a handler for this.
}
/**
* {@inheritdoc}
*/
public function setLoggers(array $loggers) {
// Do nothing.
}
/**
* {@inheritdoc}
*/
public function addLogger(LoggerInterface $logger, $priority = 0) {
// Do nothing.
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Logger:: |
protected | property | Map of RFC 5424 log constants to Monolog log constants. | |
Logger:: |
public | function |
Adds a logger. Overrides LoggerChannelInterface:: |
|
Logger:: |
public | function | ||
Logger:: |
public | function |
Sets the current user. Overrides LoggerChannelInterface:: |
|
Logger:: |
public | function |
Sets the loggers for this channel. Overrides LoggerChannelInterface:: |
|
Logger:: |
public | function |
Sets the request stack. Overrides LoggerChannelInterface:: |