From 8382b5570e890a46397da496bf98154f93215ee2 Mon Sep 17 00:00:00 2001 From: Bryan Davis Date: Fri, 13 Feb 2015 18:08:21 -0700 Subject: [PATCH] Update MWLoggerMonologHandler for Monolog 1.12.0 Monolog 1.12.0 "fixed" Handler::isHandling() so that instead of a full log record it is only passed an array with the log event's level. MWLoggerMonologHandler was relying on a full record to allow inspecting the channel name and looking for a 'private' flag in the context information. Update MWLoggerMonologHandler to do legacy processing checks in Handler::write() where the full log event is present for inspection. Bug: T89313 Change-Id: Ia878c2cb6bff47d6b35ff38ba3b7ac2ea5556565 --- includes/debug/logger/monolog/Handler.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/includes/debug/logger/monolog/Handler.php b/includes/debug/logger/monolog/Handler.php index 05ac64ee25..a872d84e28 100644 --- a/includes/debug/logger/monolog/Handler.php +++ b/includes/debug/logger/monolog/Handler.php @@ -97,16 +97,6 @@ class MWLoggerMonologHandler extends \Monolog\Handler\AbstractProcessingHandler $this->useLegacyFilter = $useLegacyFilter; } - public function isHandling( array $record ) { - $levelOk = parent::isHandling( $record ); - if ( $levelOk && $this->useLegacyFilter ) { - return MWLoggerLegacyLogger::shouldEmit( - $record['channel'], $record['message'], $record['level'], $record - ); - } - return $levelOk; - } - /** * Open the log sink described by our stream URI. */ @@ -183,6 +173,18 @@ class MWLoggerMonologHandler extends \Monolog\Handler\AbstractProcessingHandler protected function write( array $record ) { + if ( $this->useLegacyFilter && + !MWLoggerLegacyLogger::shouldEmit( + $record['channel'], $record['message'], + $record['level'], $record + ) ) { + // Do not write record if we are enforcing legacy rules and they + // do not pass this message. This used to be done in isHandling(), + // but Monolog 1.12.0 made a breaking change that removed access + // to the needed channel and context information. + return; + } + if ( $this->sink === null ) { $this->openSink(); } -- 2.20.1