mundanity/drupal-logger

A watchdog() psr-3 logger for Drupal.

v1.1.2 2017-12-07 17:53 UTC

README

A simple PSR-3 implementation of a logger for Drupal watchdog calls.

Details

The PSR-3 parameter $context is passed to watchdog as variables, for use as placeholders.

class MyClass
{
    public function myMethod($param)
    {
        $this->logger->warning('Param value was @param', ['@param' => $param]);

        return $param;
    }
}

The watch dog type is set as the function or class method that called the logging code. In the example above, the watchdog type is set as MyClass::myMethod.

Controlling log levels

Log levels below a specified level can be ignored, which may help reduce noise in production systems. When the class is initiated, an optional LogLevel may be provided. Events at or below the provided LogLevel will be ignored. $logger = new WatchdogLogger(LogLevel::NOTICE);

// This debug message will be ignored.
$logger->debug('Some debugging information');

By default, no events are ignored.