class ConsoleHandler extends AbstractProcessingHandler implements EventSubscriberInterface
Writes logs to the console output depending on its verbosity setting.
It is disabled by default and gets activated as soon as a command is executed. Instead of listening to the console events, the output can also be set manually.
The minimum logging level at which this handler will be triggered depends on the verbosity setting of the console output. The default mapping is: - OutputInterface::VERBOSITY_NORMAL will show all WARNING and higher logs - OutputInterface::VERBOSITY_VERBOSE (-v) will show all NOTICE and higher logs - OutputInterface::VERBOSITY_VERY_VERBOSE (-vv) will show all INFO and higher logs - OutputInterface::VERBOSITY_DEBUG (-vvv) will show all DEBUG and higher logs, i.e. all logs
This mapping can be customized with the $verbosityLevelMap constructor parameter.
__construct(OutputInterface $output = null, bool $bubble = true, array $verbosityLevelMap = array()) | ||
isHandling(array $record) {@inheritdoc} | ||
handle(array $record) {@inheritdoc} | ||
setOutput(OutputInterface $output) Sets the console output to use for printing logs. | ||
close() Disables the output. | ||
onCommand(ConsoleCommandEvent $event) Before a command is executed, the handler gets activated and the console output is set in order to know where to write the logs. | ||
onTerminate(ConsoleTerminateEvent $event) After a command has been executed, it disables the output. | ||
static array | getSubscribedEvents() Returns an array of event names this subscriber wants to listen to. | |
write(array $record) {@inheritdoc} | ||
getDefaultFormatter() {@inheritdoc} |
OutputInterface | $output | The console output to use (the handler remains disabled when passing null until the output is set, e.g. by using console events) |
bool | $bubble | Whether the messages that are handled can bubble up the stack |
array | $verbosityLevelMap | Array that maps the OutputInterface verbosity to a minimum logging level (leave empty to use the default mapping) |
{@inheritdoc}
array | $record |
{@inheritdoc}
array | $record |
Sets the console output to use for printing logs.
OutputInterface | $output |
Disables the output.
Before a command is executed, the handler gets activated and the console output is set in order to know where to write the logs.
ConsoleCommandEvent | $event |
After a command has been executed, it disables the output.
ConsoleTerminateEvent | $event |
Returns an array of event names this subscriber wants to listen to.
The array keys are event names and the value can be:
For instance:
array | The event names to listen to |
{@inheritdoc}
array | $record |
{@inheritdoc}
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Bridge/Monolog/Handler/ConsoleHandler.html