final class TestSystemLoggerChannel in Drupal 10
Same name and namespace in other branches
- 9 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\advisory_feed_test\TestSystemLoggerChannel extends \Drupal\Core\Logger\LoggerChannel
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 |
---|---|---|---|---|
TestSystemLoggerChannel:: |
protected | property | The decorated logger.channel.system service. | |
TestSystemLoggerChannel:: |
protected | property | The state service. | |
TestSystemLoggerChannel:: |
public | function | ||
TestSystemLoggerChannel:: |
public | function | Constructs an AdvisoriesTestHttpClient object. |