class TestSystemLoggerChannel
Same name in other branches
- 9 core/modules/system/tests/modules/advisory_feed_test/src/TestSystemLoggerChannel.php \Drupal\advisory_feed_test\TestSystemLoggerChannel
- 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\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 15
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
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
LoggerChannel::$callDepth | protected | property | Number of times LoggerChannel::log() has been called for a single message. | |
LoggerChannel::$channel | protected | property | The name of the channel of this logger instance. | |
LoggerChannel::$currentUser | protected | property | The current user object. | |
LoggerChannel::$levelTranslation | protected | property | Map of PSR3 log constants to RFC 5424 log constants. | |
LoggerChannel::$loggers | protected | property | An array of arrays of \Psr\Log\LoggerInterface keyed by priority. | |
LoggerChannel::$requestStack | protected | property | The request stack object. | |
LoggerChannel::addLogger | public | function | Adds a logger. | Overrides LoggerChannelInterface::addLogger |
LoggerChannel::MAX_CALL_DEPTH | constant | Maximum call depth to self::log() for a single log message. | ||
LoggerChannel::setCurrentUser | public | function | Sets the current user. | Overrides LoggerChannelInterface::setCurrentUser |
LoggerChannel::setLoggers | public | function | Sets the loggers for this channel. | Overrides LoggerChannelInterface::setLoggers |
LoggerChannel::setRequestStack | public | function | Sets the request stack. | Overrides LoggerChannelInterface::setRequestStack |
LoggerChannel::sortLoggers | protected | function | Sorts loggers according to priority. | |
TestSystemLoggerChannel::$innerLogger | protected | property | The decorated logger.channel.system service. | |
TestSystemLoggerChannel::$state | protected | property | The state service. | |
TestSystemLoggerChannel::log | public | function | Overrides LoggerChannel::log | |
TestSystemLoggerChannel::__construct | public | function | Constructs an AdvisoriesTestHttpClient object. | Overrides LoggerChannel::__construct |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.