MediaWiki
REL1_41
SyslogHandler.php
Go to the documentation of this file.
1
<?php
21
namespace
MediaWiki\Logger\Monolog
;
22
23
use DateTimeInterface;
24
use Monolog\Handler\SyslogUdpHandler;
25
use Monolog\Logger;
26
51
class
SyslogHandler
extends
SyslogUdpHandler {
52
53
private
string
$appname;
54
private
string
$hostname;
55
66
public
function
__construct
(
67
$appname,
68
$host,
69
$port = 514,
70
$facility = LOG_USER,
71
$level = Logger::DEBUG,
72
$bubble =
true
73
) {
74
parent::__construct( $host, $port, $facility, $level, $bubble );
75
$this->appname = $appname;
76
$this->hostname = php_uname(
'n'
);
77
}
78
79
protected
function
makeCommonSyslogHeader
(
int
$severity, DateTimeInterface $datetime ): string {
80
$pri = $severity + $this->facility;
81
82
// Goofy date format courtesy of RFC 3164 :(
83
// RFC 3164 actually specifies that the day of month should be space
84
// padded rather than unpadded but this seems to work with rsyslog and
85
// Logstash.
86
$timestamp = date(
'M j H:i:s'
);
87
88
return
"<{$pri}>{$timestamp} {$this->hostname} {$this->appname}: "
;
89
}
90
}
MediaWiki\Logger\Monolog\SyslogHandler
Write logs to a syslog server, using RFC 3164 formatted UDP packets.
Definition
SyslogHandler.php:51
MediaWiki\Logger\Monolog\SyslogHandler\makeCommonSyslogHeader
makeCommonSyslogHeader(int $severity, DateTimeInterface $datetime)
Definition
SyslogHandler.php:79
MediaWiki\Logger\Monolog\SyslogHandler\__construct
__construct( $appname, $host, $port=514, $facility=LOG_USER, $level=Logger::DEBUG, $bubble=true)
Definition
SyslogHandler.php:66
MediaWiki\Logger\Monolog
Definition
BufferHandler.php:21
includes
debug
logger
monolog
SyslogHandler.php
Generated on Wed Nov 27 2024 07:23:08 for MediaWiki by
1.10.0