MediaWiki master
MediaWiki\Logger\Monolog\LegacyHandler Class Reference

Monolog imitation of MediaWiki\Logger\LegacyLogger. More...

Inherits AbstractProcessingHandler.

Collaboration diagram for MediaWiki\Logger\Monolog\LegacyHandler:

Public Member Functions

 __construct ( $stream, $useLegacyFilter=false, $level=Logger::DEBUG, $bubble=true)
 close ()

Protected Member Functions

 errorTrap ( $code, $msg)
 Custom error handler.
 openSink ()
 Open the log sink described by our stream URI.
 useUdp ()
 Should we use UDP to send messages to the sink?
 write (array $record)

Protected Attributes

string null $error
string $host
int $port
string $prefix
Socket resource null $sink
 Log sink.
string $uri
 Log sink descriptor.
bool $useLegacyFilter
 Filter log events using legacy rules.

Detailed Description

Monolog imitation of MediaWiki\Logger\LegacyLogger.

This replicates the behavior of LegacyLogger, which in turn replicates MediaWiki's former wfErrorLog() function.

The main use case of the LegacyHandler is to enable adoption of Monolog features (such as alternate formatters, extra processors, and enabling multiple destinations/handlers at the same time), where one of the handlers (this one) essentiallly does what the LegacySpi would do if you hadn't enabled MonologSpi. In particular: writing to a file like $wgDebugLogFile, and sending messages to a PHP stream or udp2log server.

For udp2log output, the stream specification must have the form: "udp://HOST:PORT[/PREFIX]" where:

  • HOST: IPv4, IPv6 or hostname
  • PORT: server port
  • PREFIX: optional (but recommended) prefix telling udp2log how to route the log event. The special prefix "{channel}" will use the log event's channel as the prefix value.

When not targeting a udp2log server, this class will act as a drop-in replacement for \Monolog\Handler\StreamHandler.

© 2013 Wikimedia Foundation and contributors

Definition at line 60 of file LegacyHandler.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Logger\Monolog\LegacyHandler::__construct ( $stream,
$useLegacyFilter = false,
$level = Logger::DEBUG,
$bubble = true )
string$streamStream URI
bool$useLegacyFilterFilter log events using legacy rules
int$levelMinimum logging level that will trigger handler
bool$bubbleCan handled messages bubble up the handler stack?

Definition at line 106 of file LegacyHandler.php.

References MediaWiki\Logger\Monolog\LegacyHandler\$useLegacyFilter.

Member Function Documentation

◆ close()

MediaWiki\Logger\Monolog\LegacyHandler::close ( )

Definition at line 242 of file LegacyHandler.php.

◆ errorTrap()

MediaWiki\Logger\Monolog\LegacyHandler::errorTrap ( $code,
$msg )

Custom error handler.

int$codeError number
string$msgError message

Definition at line 178 of file LegacyHandler.php.

◆ openSink()

MediaWiki\Logger\Monolog\LegacyHandler::openSink ( )

Open the log sink described by our stream URI.

Definition at line 120 of file LegacyHandler.php.

◆ useUdp()

MediaWiki\Logger\Monolog\LegacyHandler::useUdp ( )

Should we use UDP to send messages to the sink?


Definition at line 186 of file LegacyHandler.php.

◆ write()

MediaWiki\Logger\Monolog\LegacyHandler::write ( array $record)

Definition at line 190 of file LegacyHandler.php.

Member Data Documentation

◆ $error

string null MediaWiki\Logger\Monolog\LegacyHandler::$error

Definition at line 83 of file LegacyHandler.php.

◆ $host

string MediaWiki\Logger\Monolog\LegacyHandler::$host

Definition at line 88 of file LegacyHandler.php.

◆ $port

int MediaWiki\Logger\Monolog\LegacyHandler::$port

Definition at line 93 of file LegacyHandler.php.

◆ $prefix

string MediaWiki\Logger\Monolog\LegacyHandler::$prefix

Definition at line 98 of file LegacyHandler.php.

◆ $sink

Socket resource null MediaWiki\Logger\Monolog\LegacyHandler::$sink

Log sink.

Definition at line 78 of file LegacyHandler.php.

◆ $uri

string MediaWiki\Logger\Monolog\LegacyHandler::$uri

Log sink descriptor.

Definition at line 66 of file LegacyHandler.php.

◆ $useLegacyFilter

bool MediaWiki\Logger\Monolog\LegacyHandler::$useLegacyFilter

Filter log events using legacy rules.

Definition at line 72 of file LegacyHandler.php.

Referenced by MediaWiki\Logger\Monolog\LegacyHandler\__construct().

The documentation for this class was generated from the following file: