class DrupalConsoleLog in Apigee Edge 8
Redirects Drupal logging messages to Drupal Console log.
Hierarchy
- class \Drupal\apigee_edge\Command\DrupalConsoleLog implements \Psr\Log\LoggerInterface uses RfcLoggerTrait
Expanded class hierarchy of DrupalConsoleLog
File
- src/
Command/ DrupalConsoleLog.php, line 31
Namespace
Drupal\apigee_edge\CommandView source
class DrupalConsoleLog implements LoggerInterface {
use RfcLoggerTrait;
/**
* The message's placeholders parser.
*
* @var \Drupal\Core\Logger\LogMessageParserInterface
*/
protected $logMessageParser;
/**
* The logger that messages will be passed through to.
*
* @var \Psr\Log\LoggerInterface
*/
protected $logger;
/**
* Constructs a DrupalConsoleLog object.
*
* @param \Drupal\Core\Logger\LogMessageParserInterface $log_message_parser
* The parser to use when extracting message variables.
* @param \Psr\Log\LoggerInterface $logger
* The logger instance.
*/
public function __construct(LogMessageParserInterface $log_message_parser, LoggerInterface $logger) {
$this->logMessageParser = $log_message_parser;
$this->logger = $logger;
}
/**
* {@inheritdoc}
*/
public function log($level, $message, array $context = []) {
switch ($level) {
case RfcLogLevel::ERROR:
$error_type = LogLevel::ERROR;
break;
case RfcLogLevel::WARNING:
$error_type = LogLevel::WARNING;
break;
case RfcLogLevel::DEBUG:
$error_type = LogLevel::DEBUG;
break;
case RfcLogLevel::INFO:
$error_type = LogLevel::INFO;
break;
case RfcLogLevel::NOTICE:
$error_type = LogLevel::NOTICE;
break;
default:
$error_type = $level;
break;
}
$message_placeholders = $this->logMessageParser
->parseMessagePlaceholders($message, $context);
$message_placeholders = array_filter($message_placeholders, function ($element) {
return is_scalar($element) || is_callable([
$element,
'__toString',
]);
});
$message = empty($message_placeholders) ? $message : strtr($message, $message_placeholders);
$this->logger
->log($error_type, $message, $context);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DrupalConsoleLog:: |
protected | property | The logger that messages will be passed through to. | |
DrupalConsoleLog:: |
protected | property | The message's placeholders parser. | |
DrupalConsoleLog:: |
public | function |
Logs with an arbitrary level. Overrides RfcLoggerTrait:: |
|
DrupalConsoleLog:: |
public | function | Constructs a DrupalConsoleLog object. | |
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function |