Phergie\Irc\Client\React\Client::getOutputLogCallback PHP Method

getOutputLogCallback() protected method

Generates a closure for stream output logging.
protected getOutputLogCallback ( Phergie\Irc\ConnectionInterface $connection, string $level, string $prefix = null ) : callable
$connection Phergie\Irc\ConnectionInterface
$level string Evenement logging level to use
$prefix string Prefix string for log lines (optional)
return callable
    protected function getOutputLogCallback(ConnectionInterface $connection, $level, $prefix = null)
    {
        $logger = $this->getLogger();
        if (!method_exists($logger, $level)) {
            throw new \DomainException("Invalid log level '{$level}'");
        }
        return function ($message) use($connection, $level, $prefix, $logger) {
            $output = sprintf('%s %s%s', $connection->getMask(), $prefix, trim($message));
            call_user_func(array($logger, $level), $output);
        };
    }