/** * Generates a closure for stream output logging. * * @param \Phergie\Irc\ConnectionInterface $connection * @param string $level Evenement logging level to use * @param string $prefix Prefix string for log lines (optional) * @return callable * @throws \DomainException if $level is not a valid logging level */ 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); }; }
/** * Add connections to pool * * @param ConnectionInterface $connection */ public function addConnection(ConnectionInterface $connection) { $this->connections[$connection->getMask()] = $connection; }