DeduplicatingLogger
extends AbstractLogger
in package
Suppresses a repeat of a log message already seen, at a configurable granularity -- see {@see LogDeduplicationLevel}.
A single document tree gets rendered once per configured output format (html, tex, interlink, ...), so a warning raised while rendering a node -- a broken image reference, an unsupported directive -- fires again, identically, for every format. Parse- and compile-time messages don't have this problem: those phases each run exactly once per invocation regardless of how many output formats are configured. The same problem recurring on different pages is a related but distinct case, since it isn't a byte-identical repeat -- LogDeduplicationLevel::Message covers that by dropping context (rst-file, line, ...) from the key.
Table of Contents
Properties
- $level : LogDeduplicationLevel
- $logger : LoggerInterface
- $seen : array<string, true>
- $suppressedCount : int
Methods
- __construct() : mixed
- log() : void
- logSuppressedSummary() : void
- Reports, as one final log line, how many repeat messages this run suppressed -- a per-line count isn't available since a message already written can't be edited once a later repeat of it turns up. A no-op when nothing was suppressed (including when the level is {@see LogDeduplicationLevel::None}, which never suppresses).
Properties
$level read-only
private
LogDeduplicationLevel
$level
$logger read-only
private
LoggerInterface
$logger
$seen
private
array<string, true>
$seen
= []
$suppressedCount
private
int
$suppressedCount
= 0
Methods
__construct()
public
__construct(LoggerInterface $logger[, LogDeduplicationLevel|string $level = LogDeduplicationLevel::None ]) : mixed
Parameters
- $logger : LoggerInterface
- $level : LogDeduplicationLevel|string = LogDeduplicationLevel::None
log()
public
log(mixed $level, string|Stringable $message[, array $context = [] ]) : void
Parameters
- $level : mixed
- $message : string|Stringable
- $context : array = []
logSuppressedSummary()
Reports, as one final log line, how many repeat messages this run suppressed -- a per-line count isn't available since a message already written can't be edited once a later repeat of it turns up. A no-op when nothing was suppressed (including when the level is {@see LogDeduplicationLevel::None}, which never suppresses).
public
logSuppressedSummary() : void
Call once, after the whole run finishes; calling it again reports only whatever was suppressed since the previous call.