From: Bryan Davis Date: Sun, 25 Oct 2015 21:39:44 +0000 (-0600) Subject: MonologSpi: add support for customizing Monolog\Logger instances X-Git-Tag: 1.31.0-rc.0~9103 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/gestion/rappel_supprimer.php?a=commitdiff_plain;h=f2db70dc14d1ed687d9952587a5710a03162fb9f;p=lhc%2Fweb%2Fwiklou.git MonologSpi: add support for customizing Monolog\Logger instances Proposed upstream changes to Monolog\Logger will require an ability to call setter methods on newly created Logger instances to tune them for use in high volume logging situations. Adding support for making these types of adjustments to MediaWiki's Monolog integration will benefit users of the updated library when they land upstream. Arbitrary setters are called by adding a 'calls' array to the logger specification. This array uses method names as keys and method arguments as values. This syntax mirrors the setter invocation behavior of ObjectFactory with the notable omission of Closure expansion in the argument list before calling the Logger's setter method. Bug: T116550 Change-Id: I990c7f00f57451f14954542f5404491b2660a0b7 --- diff --git a/includes/debug/logger/MonologSpi.php b/includes/debug/logger/MonologSpi.php index 274e18e1d0..685abe0e49 100644 --- a/includes/debug/logger/MonologSpi.php +++ b/includes/debug/logger/MonologSpi.php @@ -205,6 +205,12 @@ class MonologSpi implements Spi { protected function createLogger( $channel, $spec ) { $obj = new Logger( $channel ); + if ( isset( $spec['calls'] ) ) { + foreach ( $spec['calls'] as $method => $margs ) { + call_user_func_array( array( $obj, $method ), $margs ); + } + } + if ( isset( $spec['processors'] ) ) { foreach ( $spec['processors'] as $processor ) { $obj->pushProcessor( $this->getProcessor( $processor ) );