From f2db70dc14d1ed687d9952587a5710a03162fb9f Mon Sep 17 00:00:00 2001 From: Bryan Davis Date: Sun, 25 Oct 2015 15:39:44 -0600 Subject: [PATCH] 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 --- includes/debug/logger/MonologSpi.php | 6 ++++++ 1 file changed, 6 insertions(+) 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 ) ); -- 2.20.1