You are here

public function TestSystemLoggerChannel::log in Drupal 10

Same name and namespace in other branches
  1. 9 core/modules/system/tests/modules/advisory_feed_test/src/TestSystemLoggerChannel.php \Drupal\advisory_feed_test\TestSystemLoggerChannel::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);
}