MediaWiki  1.30.0
SyslogHandler.php
Go to the documentation of this file.
1 <?php
21 namespace MediaWiki\Logger\Monolog;
22 
23 use Monolog\Handler\SyslogUdpHandler;
24 use Monolog\Logger;
25 
48 class SyslogHandler extends SyslogUdpHandler {
49 
53  private $appname;
54 
58  private $hostname;
59 
70  public function __construct(
71  $appname,
72  $host,
73  $port = 514,
74  $facility = LOG_USER,
75  $level = Logger::DEBUG,
76  $bubble = true
77  ) {
78  parent::__construct( $host, $port, $facility, $level, $bubble );
79  $this->appname = $appname;
80  $this->hostname = php_uname( 'n' );
81  }
82 
83  protected function makeCommonSyslogHeader( $severity ) {
84  $pri = $severity + $this->facility;
85 
86  // Goofy date format courtesy of RFC 3164 :(
87  // RFC 3164 actually specifies that the day of month should be space
88  // padded rather than unpadded but this seems to work with rsyslog and
89  // Logstash.
90  $timestamp = date( 'M j H:i:s' );
91 
92  return "<{$pri}>{$timestamp} {$this->hostname} {$this->appname}: ";
93  }
94 }
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
MediaWiki\Logger\Monolog
Definition: AvroFormatter.php:21
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
MediaWiki\Logger\Monolog\SyslogHandler\$hostname
$hostname
Definition: SyslogHandler.php:58
MediaWiki\Logger\Monolog\SyslogHandler\makeCommonSyslogHeader
makeCommonSyslogHeader( $severity)
Definition: SyslogHandler.php:83
MediaWiki\Logger\Monolog\SyslogHandler
Log handler that supports sending log events to a syslog server using RFC 3164 formatted UDP packets.
Definition: SyslogHandler.php:48
MediaWiki\Logger\Monolog\SyslogHandler\$appname
$appname
Definition: SyslogHandler.php:53
MediaWiki\Logger\Monolog\SyslogHandler\__construct
__construct( $appname, $host, $port=514, $facility=LOG_USER, $level=Logger::DEBUG, $bubble=true)
Definition: SyslogHandler.php:70