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
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 ) );