mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-05 20:57:36 +02:00
Merge pull request #1304 from dominikkukacka/feature/syslog-udp-rfc3164
Add possibility to use RFC3164 for udp syslog
This commit is contained in:
@@ -69,6 +69,36 @@ class SyslogUdpHandlerTest extends TestCase
|
||||
$handler->handle($this->getRecordWithMessage(null));
|
||||
}
|
||||
|
||||
|
||||
public function testRfc()
|
||||
{
|
||||
$time = 'Mar 22 21:16:47';
|
||||
$pid = getmypid();
|
||||
$host = gethostname();
|
||||
|
||||
$handler = $this->getMockBuilder('\Monolog\Handler\SyslogUdpHandler')
|
||||
->setConstructorArgs(array("127.0.0.1", 514, "authpriv", null, null, "php", \Monolog\Handler\SyslogUdpHandler::RFC3164))
|
||||
->setMethods(array('getDateTime'))
|
||||
->getMock();
|
||||
|
||||
$handler->method('getDateTime')
|
||||
->willReturn($time);
|
||||
|
||||
$handler->setFormatter(new \Monolog\Formatter\ChromePHPFormatter());
|
||||
|
||||
$socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('write'), array('lol', 'lol'));
|
||||
$socket->expects($this->at(0))
|
||||
->method('write')
|
||||
->with("lol", "<".(LOG_AUTHPRIV + LOG_WARNING).">$time $host php[$pid]: ");
|
||||
$socket->expects($this->at(1))
|
||||
->method('write')
|
||||
->with("hej", "<".(LOG_AUTHPRIV + LOG_WARNING).">$time $host php[$pid]: ");
|
||||
|
||||
$handler->setSocket($socket);
|
||||
|
||||
$handler->handle($this->getRecordWithMessage("hej\nlol"));
|
||||
}
|
||||
|
||||
protected function getRecordWithMessage($msg)
|
||||
{
|
||||
return array('message' => $msg, 'level' => \Monolog\Logger::WARNING, 'context' => null, 'extra' => array(), 'channel' => 'lol');
|
||||
|
Reference in New Issue
Block a user