mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-04 12:17:35 +02:00
Merge remote-tracking branch 'Pierre-Lannoy/patch-1'
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace Monolog\Handler;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Monolog\Logger;
|
||||
use Monolog\Handler\SyslogUdp\UdpSocket;
|
||||
|
||||
@@ -57,7 +58,7 @@ class SyslogUdpHandler extends AbstractSyslogHandler
|
||||
{
|
||||
$lines = $this->splitMessageIntoLines($record['formatted']);
|
||||
|
||||
$header = $this->makeCommonSyslogHeader($this->logLevels[$record['level']]);
|
||||
$header = $this->makeCommonSyslogHeader($this->logLevels[$record['level']], $record['datetime']);
|
||||
|
||||
foreach ($lines as $line) {
|
||||
$this->socket->write($line, $header);
|
||||
@@ -81,7 +82,7 @@ class SyslogUdpHandler extends AbstractSyslogHandler
|
||||
/**
|
||||
* Make common syslog header (see rfc5424 or rfc3164)
|
||||
*/
|
||||
protected function makeCommonSyslogHeader(int $severity): string
|
||||
protected function makeCommonSyslogHeader(int $severity, DateTimeInterface $datetime): string
|
||||
{
|
||||
$priority = $severity + $this->facility;
|
||||
|
||||
@@ -93,7 +94,10 @@ class SyslogUdpHandler extends AbstractSyslogHandler
|
||||
$hostname = '-';
|
||||
}
|
||||
|
||||
$date = $this->getDateTime();
|
||||
if ($this->rfc === self::RFC3164) {
|
||||
$datetime->setTimezone(new \DateTimeZone('UTC'));
|
||||
}
|
||||
$date = $datetime->format($this->dateFormats[$this->rfc]);
|
||||
|
||||
if ($this->rfc === self::RFC3164) {
|
||||
return "<$priority>" .
|
||||
@@ -109,11 +113,6 @@ class SyslogUdpHandler extends AbstractSyslogHandler
|
||||
}
|
||||
}
|
||||
|
||||
protected function getDateTime(): string
|
||||
{
|
||||
return date($this->dateFormats[$this->rfc]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inject your own socket, mainly used for testing
|
||||
*/
|
||||
|
Reference in New Issue
Block a user