src/Viserio/Component/WebServer/Command/ServerLogCommand.php
public function handle(): int
    {
        $output        = $this->getOutput();
        $this->handler = new ConsoleHandler($output);
        $format        = $this->hasOption('format') ? $this->option('format') : ConsoleFormatter::SIMPLE_FORMAT;
        $dateFormat    = $this->hasOption('date-format') ? $this->option('date-format') : ConsoleFormatter::SIMPLE_DATE;

        $this->handler->setFormatter(new ConsoleFormatter([
            'format'      => \str_replace('\n', "\n", $format),
            'date_format' => $dateFormat,
            'colors'      => $output->isDecorated(),
            'multiline'   => OutputInterface::VERBOSITY_DEBUG <= $output->getVerbosity(),
        ]));

        $host    = $this->option('host');
        $port    = $this->option('port');
        $address = 'tcp://' . $host . ':' . $port;

        if (! $socket = \stream_socket_server($address, $errno, $errstr)) {
            throw new RuntimeException(\sprintf('Server start failed on "%s": %s %s.', $address, $errstr, $errno));
        }

        $output->success(\sprintf(
            'Server listening on %s',
            $host !== '0.0.0.0' ? $host . ':' . $port : 'all interfaces, port ' . $port
        ));

        foreach ($this->getLogs($socket) as $clientId => $message) {
            $record = \unserialize(\base64_decode($message, true));

            // Impossible to decode the message, give up.
            if ($record === false) {
                continue;
            }

            $this->displayLog($output, $clientId, $record);
        }

        return 0;
    }
public function handle(): int
    {
        $output        = $this->getOutput();
        $this->handler = new ConsoleHandler($output);
        $format        = $this->hasOption('format') ? $this->option('format') : ConsoleFormatter::SIMPLE_FORMAT;
        $dateFormat    = $this->hasOption('date-format') ? $this->option('date-format') : ConsoleFormatter::SIMPLE_DATE;

        $this->handler->setFormatter(new ConsoleFormatter([
            'format'      => \str_replace('\n', "\n", $format),
            'date_format' => $dateFormat,
            'colors'      => $output->isDecorated(),
            'multiline'   => OutputInterface::VERBOSITY_DEBUG <= $output->getVerbosity(),
        ]));

        $host    = $this->option('host');
        $port    = $this->option('port');
        $address = 'tcp://' . $host . ':' . $port;

        if (! $socket = \stream_socket_server($address, $errno, $errstr)) {
            throw new RuntimeException(\sprintf('Server start failed on "%s": %s %s.', $address, $errstr, $errno));
        }

        $output->success(\sprintf(
            'Server listening on %s',
            $host !== '0.0.0.0' ? $host . ':' . $port : 'all interfaces, port ' . $port
        ));

        foreach ($this->getLogs($socket) as $clientId => $message) {
            $record = \unserialize(\base64_decode($message, true));

            // Impossible to decode the message, give up.
            if ($record === false) {
                continue;
            }

            $this->displayLog($output, $clientId, $record);
        }

        return 0;
    }
{@inheritdoc}