function TestLog::log

Same name in other branches
  1. 9 core/modules/system/tests/modules/error_service_test/src/Logger/TestLog.php \Drupal\error_service_test\Logger\TestLog::log()
  2. 8.9.x core/modules/system/tests/modules/error_service_test/src/Logger/TestLog.php \Drupal\error_service_test\Logger\TestLog::log()
  3. 11.x core/modules/system/tests/modules/error_service_test/src/Logger/TestLog.php \Drupal\error_service_test\Logger\TestLog::log()

Overrides RfcLoggerTrait::log

File

core/modules/system/tests/modules/error_service_test/src/Logger/TestLog.php, line 19

Class

TestLog
Throws an exception while logging an exception.

Namespace

Drupal\error_service_test\Logger

Code

public function log($level, string|\Stringable $message, array $context = []) : void {
    $trigger = [
        '%type' => 'Exception',
        '@message' => 'Deforestation',
        '%function' => 'Drupal\\error_service_test\\MonkeysInTheControlRoom->handle()',
        'severity_level' => 3,
        'channel' => 'php',
    ];
    if (array_diff_assoc($trigger, $context) === []) {
        throw new \Exception('Oh, oh, frustrated monkeys!');
    }
}

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