MediaWiki REL1_33
MwlogHandler.php
Go to the documentation of this file.
1<?php
22
25
37class MwlogHandler extends SyslogUdpHandler {
38
42 private $appprefix;
43
47 private $hostname;
48
59 public function __construct(
61 $host,
62 $port = 514,
63 $facility = LOG_USER,
64 $level = Logger::DEBUG,
65 $bubble = true
66 ) {
67 parent::__construct( $host, $port, $facility, $level, $bubble );
68 $this->appprefix = $appprefix;
69 $this->hostname = php_uname( 'n' );
70 }
71
72 protected function syslogHeader( $severity, $app ) {
73 $pri = $severity + $this->facility;
74
75 // Goofy date format courtesy of RFC 3164 :(
76 // RFC 3164 actually specifies that the day of month should be space
77 // padded rather than unpadded but this seems to work with rsyslog and
78 // Logstash.
79 $timestamp = date( 'M j H:i:s' );
80
81 return "<{$pri}>{$timestamp} {$this->hostname} {$app}: ";
82 }
83
84 private function splitMessageIntoLines( $message ): array {
85 if ( is_array( $message ) ) {
86 $message = implode( "\n", $message );
87 }
88
89 return preg_split( '/$\R?^/m', (string)$message, -1, PREG_SPLIT_NO_EMPTY );
90 }
91
92 protected function write( array $record ) {
93 $lines = $this->splitMessageIntoLines( $record['formatted'] );
94 $header = $this->syslogHeader(
95 $this->logLevels[$record['level']],
96 $this->appprefix . $record['channel'] );
97
98 foreach ( $lines as $line ) {
99 $this->socket->write( $line, $header );
100 }
101 }
102}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
$line
Definition cdb.php:59
Log handler that will append the record's channel to a fixed 'application prefix' given at constructi...
__construct( $appprefix, $host, $port=514, $facility=LOG_USER, $level=Logger::DEBUG, $bubble=true)
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
$lines
Definition router.php:61
$header