final class TestSystemLoggerChannel in Drupal 9
Same name and namespace in other branches
- 10 core/modules/system/tests/modules/advisory_feed_test/src/TestSystemLoggerChannel.php \Drupal\advisory_feed_test\TestSystemLoggerChannel
Provides a decorator for the 'logger.channel.system' service for testing.
Hierarchy
- class \Drupal\Core\Logger\LoggerChannel implements LoggerChannelInterface uses \Psr\Log\LoggerTrait
- class \Drupal\advisory_feed_test\TestSystemLoggerChannel
Expanded class hierarchy of TestSystemLoggerChannel
1 string reference to 'TestSystemLoggerChannel'
- advisory_feed_test.services.yml in core/
modules/ system/ tests/ modules/ advisory_feed_test/ advisory_feed_test.services.yml - core/modules/system/tests/modules/advisory_feed_test/advisory_feed_test.services.yml
1 service uses TestSystemLoggerChannel
- logger.advisory_feed_test in core/
modules/ system/ tests/ modules/ advisory_feed_test/ advisory_feed_test.services.yml - Drupal\advisory_feed_test\TestSystemLoggerChannel
File
- core/
modules/ system/ tests/ modules/ advisory_feed_test/ src/ TestSystemLoggerChannel.php, line 13
Namespace
Drupal\advisory_feed_testView source
final class TestSystemLoggerChannel extends LoggerChannel {
/**
* The decorated logger.channel.system service.
*
* @var \Drupal\Core\Logger\LoggerChannelInterface
*/
protected $innerLogger;
/**
* The state service.
*
* @var \Drupal\Core\State\StateInterface
*/
protected $state;
/**
* Constructs an AdvisoriesTestHttpClient object.
*
* @param \Drupal\Core\Logger\LoggerChannelInterface $inner_logger
* The decorated logger.channel.system service.
* @param \Drupal\Core\State\StateInterface $state
* The state service.
*/
public function __construct(LoggerChannelInterface $inner_logger, StateInterface $state) {
$this->innerLogger = $inner_logger;
$this->state = $state;
}
/**
* {@inheritdoc}
*
* @see \Drupal\Tests\system\Functional\SecurityAdvisories\SecurityAdvisoriesTestTrait::assertServiceAdvisoryLoggedErrors()
*/
public function log($level, $message, array $context = []) : void {
if ($level === LogLevel::ERROR) {
$messages = $this->state
->get('advisory_feed_test.error_messages', []);
$messages[] = $message;
$this->state
->set('advisory_feed_test.error_messages', $messages);
}
$this->innerLogger
->log($level, $message, $context);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LoggerChannel:: |
protected | property | Number of times LoggerChannel::log() has been called for a single message. | |
LoggerChannel:: |
protected | property | The name of the channel of this logger instance. | |
LoggerChannel:: |
protected | property | The current user object. | |
LoggerChannel:: |
protected | property | Map of PSR3 log constants to RFC 5424 log constants. | |
LoggerChannel:: |
protected | property | An array of arrays of \Psr\Log\LoggerInterface keyed by priority. | |
LoggerChannel:: |
protected | property | The request stack object. | |
LoggerChannel:: |
public | function |
Adds a logger. Overrides LoggerChannelInterface:: |
|
LoggerChannel:: |
constant | Maximum call depth to self::log() for a single log message. | ||
LoggerChannel:: |
public | function |
Sets the current user. Overrides LoggerChannelInterface:: |
|
LoggerChannel:: |
public | function |
Sets the loggers for this channel. Overrides LoggerChannelInterface:: |
|
LoggerChannel:: |
public | function |
Sets the request stack. Overrides LoggerChannelInterface:: |
|
LoggerChannel:: |
protected | function | Sorts loggers according to priority. | |
TestSystemLoggerChannel:: |
protected | property | The decorated logger.channel.system service. | |
TestSystemLoggerChannel:: |
protected | property | The state service. | |
TestSystemLoggerChannel:: |
public | function |
Overrides LoggerChannel:: |
|
TestSystemLoggerChannel:: |
public | function |
Constructs an AdvisoriesTestHttpClient object. Overrides LoggerChannel:: |