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);
        };
    }