* @return bool True if message should be sent to disk/network, false
* otherwise
*/
- protected static function shouldEmit( $channel, $message, $context ) {
+ public static function shouldEmit( $channel, $message, $context ) {
global $wgDebugLogFile, $wgDBerrorLog, $wgDebugLogGroups;
if ( $channel === 'wfLogDBError' ) {
}
} elseif ( isset( $context['private'] ) && $context['private'] ) {
- // Don't emit if the message didn't match previous checks based on the
- // channel and the event is marked as private. This check discards
- // messages sent via wfDebugLog() with dest == 'private' and no explicit
- // wgDebugLogGroups configuration.
+ // Don't emit if the message didn't match previous checks based on
+ // the channel and the event is marked as private. This check
+ // discards messages sent via wfDebugLog() with dest == 'private'
+ // and no explicit wgDebugLogGroups configuration.
$shouldEmit = false;
} else {
// Default return value is the the same as the historic wfDebug
*/
protected $uri;
+ /**
+ * Filter log events using legacy rules
+ * @var bool $useLegacyFilter
+ */
+ protected $useLegacyFilter;
+
/**
* Log sink
* @var resource $sink
/**
* @param string $stream Stream URI
+ * @param bool $useLegacyFilter Filter log events using legacy rules
* @param int $level Minimum logging level that will trigger handler
* @param bool $bubble Can handled meesages bubble up the handler stack?
*/
public function __construct(
- $stream, $level = \Monolog\Logger::DEBUG, $bubble = true
+ $stream,
+ $useLegacyFilter = false,
+ $level = \Monolog\Logger::DEBUG,
+ $bubble = true
) {
parent::__construct( $level, $bubble );
$this->uri = $stream;
+ $this->useLegacyFilter = $useLegacyFilter;
}
+ public function isHandling( array $record ) {
+ $levelOk = parent::isHandling( $record );
+ if ( $levelOk && $this->useLegacyFilter ) {
+ return MWLoggerLegacyLogger::shouldEmit(
+ $record['channel'], $record['message'], $record
+ );
+ }
+ return $levelOk;
+ }
/**
* Open the log sink described by our stream URI.