"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "public_html/lists/base/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdpHandler.php" between
phplist-3.4.5.tgz and phplist-3.4.6.tgz

About: phpList is a one-way email announcement delivery system for newsletters, publicity lists, notifications, and many other uses (requires PHP and MySQL).

SyslogUdpHandler.php  (phplist-3.4.5.tgz):SyslogUdpHandler.php  (phplist-3.4.6.tgz)
skipping to change at line 21 skipping to change at line 21
namespace Monolog\Handler; namespace Monolog\Handler;
use Monolog\Logger; use Monolog\Logger;
use Monolog\Handler\SyslogUdp\UdpSocket; use Monolog\Handler\SyslogUdp\UdpSocket;
/** /**
* A Handler for logging to a remote syslogd server. * A Handler for logging to a remote syslogd server.
* *
* @author Jesper Skovgaard Nielsen <nulpunkt@gmail.com> * @author Jesper Skovgaard Nielsen <nulpunkt@gmail.com>
* @author Dominik Kukacka <dominik.kukacka@gmail.com>
*/ */
class SyslogUdpHandler extends AbstractSyslogHandler class SyslogUdpHandler extends AbstractSyslogHandler
{ {
const RFC3164 = 0;
const RFC5424 = 1;
private $dateFormats = array(
self::RFC3164 => 'M d H:i:s',
self::RFC5424 => \DateTime::RFC3339,
);
protected $socket; protected $socket;
protected $ident; protected $ident;
protected $rfc;
/** /**
* @param string $host * @param string $host
* @param int $port * @param int $port
* @param mixed $facility * @param mixed $facility
* @param int $level The minimum logging level at which this handler w ill be triggered * @param int $level The minimum logging level at which this handler w ill be triggered
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not * @param bool $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. * @param string $ident Program name or tag for each log message.
* @param int $rfc RFC to format the message for.
*/ */
public function __construct($host, $port = 514, $facility = LOG_USER, $level = Logger::DEBUG, $bubble = true, $ident = 'php') public function __construct($host, $port = 514, $facility = LOG_USER, $level = Logger::DEBUG, $bubble = true, $ident = 'php', $rfc = self::RFC5424)
{ {
parent::__construct($facility, $level, $bubble); parent::__construct($facility, $level, $bubble);
$this->ident = $ident; $this->ident = $ident;
$this->rfc = $rfc;
$this->socket = new UdpSocket($host, $port ?: 514); $this->socket = new UdpSocket($host, $port ?: 514);
} }
protected function write(array $record) protected function write(array $record)
{ {
$lines = $this->splitMessageIntoLines($record['formatted']); $lines = $this->splitMessageIntoLines($record['formatted']);
$header = $this->makeCommonSyslogHeader($this->logLevels[$record['level' ]]); $header = $this->makeCommonSyslogHeader($this->logLevels[$record['level' ]]);
skipping to change at line 70 skipping to change at line 82
private function splitMessageIntoLines($message) private function splitMessageIntoLines($message)
{ {
if (is_array($message)) { if (is_array($message)) {
$message = implode("\n", $message); $message = implode("\n", $message);
} }
return preg_split('/$\R?^/m', $message, -1, PREG_SPLIT_NO_EMPTY); return preg_split('/$\R?^/m', $message, -1, PREG_SPLIT_NO_EMPTY);
} }
/** /**
* Make common syslog header (see rfc5424) * Make common syslog header (see rfc5424 or rfc3164)
*/ */
protected function makeCommonSyslogHeader($severity) protected function makeCommonSyslogHeader($severity)
{ {
$priority = $severity + $this->facility; $priority = $severity + $this->facility;
if (!$pid = getmypid()) { if (!$pid = getmypid()) {
$pid = '-'; $pid = '-';
} }
if (!$hostname = gethostname()) { if (!$hostname = gethostname()) {
$hostname = '-'; $hostname = '-';
} }
return "<$priority>1 " . $date = $this->getDateTime();
$this->getDateTime() . " " .
$hostname . " " . if ($this->rfc === self::RFC3164) {
$this->ident . " " . return "<$priority>" .
$pid . " - - "; $date . " " .
$hostname . " " .
$this->ident . "[" . $pid . "]: ";
} else {
return "<$priority>1 " .
$date . " " .
$hostname . " " .
$this->ident . " " .
$pid . " - - ";
}
} }
protected function getDateTime() protected function getDateTime()
{ {
return date(\DateTime::RFC3339); return date($this->dateFormats[$this->rfc]);
} }
/** /**
* Inject your own socket, mainly used for testing * Inject your own socket, mainly used for testing
*/ */
public function setSocket($socket) public function setSocket($socket)
{ {
$this->socket = $socket; $this->socket = $socket;
} }
} }
 End of changes. 9 change blocks. 
8 lines changed or deleted 29 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)