Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. NullLogger.php

class NullLogger

This Logger can be used to avoid conditional log calls.

Logging should always be optional, and if no logger is provided to your library creating a NullLogger instance to have something to throw logs at is a good way to avoid littering your code with `if ($this->logger) { }` blocks.

Hierarchy

  • class \Psr\Log\AbstractLogger implements \Psr\Log\LoggerInterface uses \Psr\Log\LoggerTrait
    • class \Psr\Log\NullLogger extends \Psr\Log\AbstractLogger

Expanded class hierarchy of NullLogger

9 files declare their use of NullLogger
AbstractTransport.php in vendor/symfony/mailer/Transport/AbstractTransport.php
ComposerInspector.php in core/modules/package_manager/src/ComposerInspector.php
Cron.php in core/lib/Drupal/Core/Cron.php
InstrumentationTrait.php in vendor/open-telemetry/api/Instrumentation/InstrumentationTrait.php
LoggerAwareTrait.php in vendor/open-telemetry/sdk/Trace/Behavior/LoggerAwareTrait.php

... See full list

File

vendor/psr/log/src/NullLogger.php, line 13

Namespace

Psr\Log
View source
class NullLogger extends AbstractLogger {
    
    /**
     * Logs with an arbitrary level.
     *
     * @param mixed[] $context
     *
     * @throws \Psr\Log\InvalidArgumentException
     */
    public function log($level, string|\Stringable $message, array $context = []) : void {
        // noop
    }

}

Members

Title Sort descending Modifiers Object type Summary
NullLogger::log public function Logs with an arbitrary level.
RSS feed
Powered by Drupal