public function logEvent(OutputInterface $output, LogEvent $event, Command $command)
    {
        $numericErrors = array(
            LogLevel::DEBUG     => 0,
            LogLevel::NOTICE    => 1,
            LogLevel::INFO      => 2,
            LogLevel::WARNING   => 3,
            LogLevel::ERROR     => 4,
            LogLevel::ALERT     => 5,
            LogLevel::CRITICAL  => 6,
            LogLevel::EMERGENCY => 7,
        );

        $threshold = LogLevel::ERROR;
        if ($output->getVerbosity() === OutputInterface::VERBOSITY_DEBUG) {
            $threshold = LogLevel::DEBUG;
        }

        if ($numericErrors[$event->getPriority()] >= $numericErrors[$threshold]) {
            /** @var Translator $translator  */
            $translator = $command->getContainer()->offsetGet('translator');
            $message    = vsprintf($translator->translate($event->getMessage()), $event->getContext());

            switch ($event->getPriority()) {
                case LogLevel::WARNING:
                    $message = '<comment>' . $message . '</comment>';
                    break;
                case LogLevel::EMERGENCY:
                case LogLevel::ALERT:
                case LogLevel::CRITICAL:
                case LogLevel::ERROR:
                    $message = '<error>' . $message . '</error>';
                    break;
            }
            $output->writeln('  ' . $message);
        }
    }
public function logEvent(OutputInterface $output, LogEvent $event, Command $command)
    {
        $numericErrors = array(
            LogLevel::DEBUG     => 0,
            LogLevel::NOTICE    => 1,
            LogLevel::INFO      => 2,
            LogLevel::WARNING   => 3,
            LogLevel::ERROR     => 4,
            LogLevel::ALERT     => 5,
            LogLevel::CRITICAL  => 6,
            LogLevel::EMERGENCY => 7,
        );

        $threshold = LogLevel::ERROR;
        if ($output->getVerbosity() === OutputInterface::VERBOSITY_DEBUG) {
            $threshold = LogLevel::DEBUG;
        }

        if ($numericErrors[$event->getPriority()] >= $numericErrors[$threshold]) {
            /** @var Translator $translator  */
            $translator = $command->getContainer()->offsetGet('translator');
            $message    = vsprintf($translator->translate($event->getMessage()), $event->getContext());

            switch ($event->getPriority()) {
                case LogLevel::WARNING:
                    $message = '<comment>' . $message . '</comment>';
                    break;
                case LogLevel::EMERGENCY:
                case LogLevel::ALERT:
                case LogLevel::CRITICAL:
                case LogLevel::ERROR:
                    $message = '<error>' . $message . '</error>';
                    break;
            }
            $output->writeln('  ' . $message);
        }
    }
public function logEvent ( OutputInterface $ output , LogEvent $ event , Command $ command ) { $ numericErrors = array ( LogLevel :: DEBUG => 0 , LogLevel :: NOTICE => 1 , LogLevel :: INFO => 2 , LogLevel :: WARNING => 3 , LogLevel :: ERROR => 4 , LogLevel :: ALERT => 5 , LogLevel :: CRITICAL => 6 , LogLevel :: EMERGENCY => 7 , ) ; $ threshold = LogLevel :: ERROR ; if ( $ output -> getVerbosity ( ) === OutputInterface :: VERBOSITY_DEBUG ) { $ threshold = LogLevel :: DEBUG ; } if ( $ numericErrors [ $ event -> getPriority ( ) ] >= $ numericErrors [ $ threshold ] ) { /** @var Translator $translator  */ $ translator = $ command -> getContainer ( ) -> offsetGet ( 'translator' ) ; $ message = vsprintf ( $ translator -> translate ( $ event -> getMessage ( ) ) , $ event -> getContext ( ) ) ; switch ( $ event -> getPriority ( ) ) { case LogLevel :: WARNING : $ message = '<comment>' . $ message . '</comment>' ; break ; case LogLevel :: EMERGENCY : case LogLevel :: ALERT : case LogLevel :: CRITICAL : case LogLevel :: ERROR : $ message = '<error>' . $ message . '</error>' ; break ; } $ output -> writeln ( '  ' . $ message ) ; } }
Logs an event with the output.

This method will also colorize the message based on priority and withhold
certain logging in case of verbosity or not.

@param OutputInterface $output
@param LogEvent        $event
@param Command         $command

@return void
Logs an event with the output .