Commit 1b097664 authored by Tim Lieberman's avatar Tim Lieberman
Browse files

Document getNullLogger in README

parent b6184004
Pipeline #38 passed with stage
in 44 seconds
......@@ -99,6 +99,25 @@ callables in your stacked context. Context is processed *before* invoking the
wrapped logger's methods. The callables will be invoked on every logging method
call, even if the underlying logger is configured to ignore the log-level.
### NullLoggers
All `StackLogger` implementations provide a static `getNullLogger()` method,
which returns an instance that is configured to discard all log messages. These
"null loggers" can be handy in tests, or as a default logger in classes that
can optionally accept a real logger:
```php
use TimDev\StackLogger\MonologStackLogger;
class SomeService
{
public function __construct(?MonologStackLogger $logger = null)
{
$this->logger = $logger ?? MonologStackLogger::getNullLogger();
}
}
```
## To Do
- [ ] Make MonologStackLogger implement Monolog's ResettableInterface?
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment