summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJordi Boggiano <j.boggiano@seld.be>2017-03-17 22:57:35 +0100
committerGitHub <noreply@github.com>2017-03-17 22:57:35 +0100
commite481c9db10c502193e184e678930a23a04f635d5 (patch)
treef5cc9fc122c3db9b3de6b4c85403e3777f04dee3 /src
parent1e044bc4b34e91743943479f1be7a1d5eb93add0 (diff)
parent24894709d1732ea8783c7ddfd8bca0bd7222f2c4 (diff)
downloadmonolog-e481c9db10c502193e184e678930a23a04f635d5.zip
monolog-e481c9db10c502193e184e678930a23a04f635d5.tar.gz
monolog-e481c9db10c502193e184e678930a23a04f635d5.tar.bz2
Merge pull request #943 from ont/1.x
Complete rfc5424 header for SyslogUdpHandler
Diffstat (limited to 'src')
-rw-r--r--src/Monolog/Handler/SyslogUdpHandler.php25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/Monolog/Handler/SyslogUdpHandler.php b/src/Monolog/Handler/SyslogUdpHandler.php
index 74d946a..4718711 100644
--- a/src/Monolog/Handler/SyslogUdpHandler.php
+++ b/src/Monolog/Handler/SyslogUdpHandler.php
@@ -22,6 +22,7 @@ use Monolog\Handler\SyslogUdp\UdpSocket;
class SyslogUdpHandler extends AbstractSyslogHandler
{
protected $socket;
+ protected $ident;
/**
* @param string $host
@@ -29,11 +30,14 @@ class SyslogUdpHandler extends AbstractSyslogHandler
* @param mixed $facility
* @param int $level The minimum logging level at which this handler will be triggered
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param string $ident Program name or tag for each log message.
*/
- public function __construct($host, $port = 514, $facility = LOG_USER, $level = Logger::DEBUG, $bubble = true)
+ public function __construct($host, $port = 514, $facility = LOG_USER, $level = Logger::DEBUG, $bubble = true, $ident = 'php')
{
parent::__construct($facility, $level, $bubble);
+ $this->ident = $ident;
+
$this->socket = new UdpSocket($host, $port ?: 514);
}
@@ -69,7 +73,24 @@ class SyslogUdpHandler extends AbstractSyslogHandler
{
$priority = $severity + $this->facility;
- return "<$priority>1 ";
+ if (!$pid = getmypid()) {
+ $pid = '-';
+ }
+
+ if (!$hostname = gethostname()) {
+ $hostname = '-';
+ }
+
+ return "<$priority>1 " .
+ $this->getDateTime() . " " .
+ $hostname . " " .
+ $this->ident . " " .
+ $pid . " - - ";
+ }
+
+ protected function getDateTime()
+ {
+ return date(\DateTime::RFC3339);
}
/**