function TestSystemLoggerChannel::log

Same name in other branches
  1. 10 core/modules/system/tests/modules/advisory_feed_test/src/TestSystemLoggerChannel.php \Drupal\advisory_feed_test\TestSystemLoggerChannel::log()
  2. 11.x core/modules/system/tests/modules/advisory_feed_test/src/TestSystemLoggerChannel.php \Drupal\advisory_feed_test\TestSystemLoggerChannel::log()

Overrides LoggerChannel::log

See also

\Drupal\Tests\system\Functional\SecurityAdvisories\SecurityAdvisoriesTestTrait::assertServiceAdvisoryLoggedErrors()

File

core/modules/system/tests/modules/advisory_feed_test/src/TestSystemLoggerChannel.php, line 47

Class

TestSystemLoggerChannel
Provides a decorator for the 'logger.channel.system' service for testing.

Namespace

Drupal\advisory_feed_test

Code

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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.