From 16afa511495bceb7c794ed9b29d8393c6a761621 Mon Sep 17 00:00:00 2001 From: Jesse Donat Date: Wed, 29 Nov 2023 23:12:05 -0600 Subject: [PATCH] Add docs for LogLevelFilter Signed-off-by: Jesse Donat --- README.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/README.md b/README.md index 1d77ef1..6dd4e92 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,41 @@ Returns a new instance with the specified verbosity level callback. function log($level, $message [, array $context = []]) : void ``` +### Class: \Corpus\Loggers\LogLevelFilter + +LogLevelFilter is a logger that filters log messages based on the log level. + +It can be used to filter out log messages that are not needed for a specific +use case. + +For example, you may want to log all messages at the DEBUG level to a file, +but only log messages at the ERROR level or higher to the console. + +This logger can be used to filter out the DEBUG messages from the console +logger. + +This logger accepts a list of log levels to filter, and a boolean indicating +whether to exclude or include the given log levels. + +#### Method: LogLevelFilter->__construct + +```php +function __construct(\Psr\Log\LoggerInterface $logger, array $levels [, bool $exclude = false]) +``` + +##### Parameters: + +- ***string[]*** `$levels` - The log levels to filter. +- ***bool*** `$exclude` - Whether to exclude the given levels, or include them. + +--- + +#### Method: LogLevelFilter->log + +```php +function log($level, $message [, array $context = []]) +``` + ### Class: \Corpus\Loggers\LogLevelLoggerMux LogLevelLoggerMux multiplexes logs to different loggers based on the log level.