AcmePhp\Cli\Command\MonitoringTestCommand::execute PHP Method

execute() protected method

protected execute ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output )
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $output->writeln('Loading monitoring configuration...');
        /** @var LoggerInterface $monitoringLogger */
        $monitoringLogger = $this->getContainer()->get('monitoring_factory')->createLogger();
        $level = $input->getArgument('level');
        if (!in_array($level, [HandlerBuilderInterface::LEVEL_ERROR, HandlerBuilderInterface::LEVEL_INFO], true)) {
            throw new AcmeCliException('Level ' . $level . ' is not valid (available levels: info, error)');
        }
        $output->writeln('Triggering monitoring on "' . $level . '" level...');
        if ($level === HandlerBuilderInterface::LEVEL_INFO) {
            $monitoringLogger->info('This is a testing message from Acme PHP monitoring (info level)');
        } else {
            $monitoringLogger->alert('This is a testing message from Acme PHP monitoring (error level)');
        }
        $output->writeln('<info>Triggered successfully</info>');
        $output->writeln('You should have been alerted');
    }
MonitoringTestCommand