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::VERBOSITYNORMAL will show all WARNING and higher logs - OutputInterface::VERBOSITYVERBOSE (-v) will show all NOTICE and higher logs - OutputInterface::VERBOSITYVERYVERBOSE (-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.
Methods
__construct(OutputInterface $output = null, bool $bubble = true, array $verbosityLevelMap = array()) Constructor. | ||
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. |
Details
__construct(OutputInterface $output = null, bool $bubble = true, array $verbosityLevelMap = array())
Constructor.
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.
The array keys are event names and the value can be:
- The method name to call (priority defaults to 0)
- An array composed of the method name to call and the priority
- An array of arrays composed of the method names to call and respective priorities, or 0 if unset
For instance:
- array('eventName' => 'methodName')
- array('eventName' => array('methodName', $priority))
- array('eventName' => array(array('methodName1', $priority), array('methodName2')))
Please login to continue.