summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authoront <ont.rif@gmail.com>2017-03-15 00:57:06 +0700
committeront <ont.rif@gmail.com>2017-03-15 00:57:06 +0700
commitaa6e88b6de881647f4c94a055fa024d774e172dc (patch)
tree0bfc979c3f59c0aa5b1d990cbade1c55fc94fc01 /src
parent1e044bc4b34e91743943479f1be7a1d5eb93add0 (diff)
downloadmonolog-aa6e88b6de881647f4c94a055fa024d774e172dc.zip
monolog-aa6e88b6de881647f4c94a055fa024d774e172dc.tar.gz
monolog-aa6e88b6de881647f4c94a055fa024d774e172dc.tar.bz2
Complete rfc5424 header for SyslogUdpHandler
WARN: this commit adds backward incompatibility for the SyslogUdpHandler constructor.
Diffstat (limited to 'src')
-rw-r--r--src/Monolog/Handler/SyslogUdpHandler.php23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/Monolog/Handler/SyslogUdpHandler.php b/src/Monolog/Handler/SyslogUdpHandler.php
index 74d946a..fb4dac8 100644
--- a/src/Monolog/Handler/SyslogUdpHandler.php
+++ b/src/Monolog/Handler/SyslogUdpHandler.php
@@ -22,18 +22,22 @@ use Monolog\Handler\SyslogUdp\UdpSocket;
class SyslogUdpHandler extends AbstractSyslogHandler
{
protected $socket;
+ protected $ident;
/**
* @param string $host
* @param int $port
+ * @param string $ident Program name or tag for each log message.
* @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
*/
- public function __construct($host, $port = 514, $facility = LOG_USER, $level = Logger::DEBUG, $bubble = true)
+ public function __construct($host, $port = 514, $ident = 'php', $facility = LOG_USER, $level = Logger::DEBUG, $bubble = true)
{
parent::__construct($facility, $level, $bubble);
+ $this->ident = $ident;
+
$this->socket = new UdpSocket($host, $port ?: 514);
}
@@ -69,7 +73,22 @@ 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);
}
/**