$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.
*/
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();
}