mundanity / drupal-logger
A watchdog() psr-3 logger for Drupal.
Installs: 3 713
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 3
Open Issues: 0
Requires
- php: ~5.3 || ~7.1
- psr/log: ~1.0.0
This package is not auto-updated.
Last update: 2024-12-23 00:31:20 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.