Skip to content

LogRegistry

Process-global store of logging configuration: the default minimum level, the per-category minimum levels, and the registered sinks.

Deliberately free of any dependency on Config / the context / bootstrap, so it can be configured in index.php BEFORE Kernel::run() and is usable during bootstrap itself. Configuration is set once at worker startup and is immutable for the worker lifetime (the only per-request logging state lives in LogContext). Log is the public facade over this store.

final class LogRegistry

SourceLogging/LogRegistry.php
MethodDescription
addSink(SinkInterface $sink): voidAppends a sink to the process-global sink list, in registration order.
generation(): intThe current configuration generation, for consumers that memoize a resolved level or sink decision of their own.
hasSinks(): boolReports whether any sink is registered.
reset(): voidReset all configuration and drop sinks.
resolveLevel(string $category): LevelResolve the minimum level for a category: the level of the longest configured prefix that matches on a dot boundary, else the default.
setDefaultLevel(Level $level): voidSets the minimum level applied to categories with no matching prefix rule.
setLevel(string $categoryPrefix, Level $level): voidSets the minimum level for one dotted category prefix, replacing any level already stored for that exact prefix.
setLevels(array<string, Level> $map): void
sinks(): list<SinkInterface>

public static function addSink(SinkInterface $sink): void

Appends a sink to the process-global sink list, in registration order.

No de-duplication is performed: registering the same sink twice makes it receive every record twice.

ParameterTypeDescription
$sinkSinkInterface

public static function generation(): int

The current configuration generation, for consumers that memoize a resolved level or sink decision of their own.

Returns int

public static function hasSinks(): bool

Reports whether any sink is registered.

False means every record is discarded regardless of level, so callers can skip building a record at all.

Returns bool

public static function reset(): void

Reset all configuration and drop sinks.

For test isolation and reconfiguration; not used on the request path.

public static function resolveLevel(string $category): Level

Resolve the minimum level for a category: the level of the longest configured prefix that matches on a dot boundary, else the default.

Memoized per exact category string.

ParameterTypeDescription
$categorystring

Returns Level

public static function setDefaultLevel(Level $level): void

Sets the minimum level applied to categories with no matching prefix rule.

Discards the resolved-threshold memo, so categories that had fallen through to the previous default are re-resolved on their next log call.

ParameterTypeDescription
$levelLevel

public static function setLevel(string $categoryPrefix, Level $level): void

Sets the minimum level for one dotted category prefix, replacing any level already stored for that exact prefix.

Discards the resolved-threshold memo so existing categories re-resolve against the new rule; see LogRegistry::resolveLevel() for how competing prefixes are ranked.

ParameterTypeDescription
$categoryPrefixstring
$levelLevel

public static function setLevels(array<string, Level> $map): void

category-prefix => Level

ParameterTypeDescription
$maparray``<``string``, Level>category-prefix => Level

public static function sinks(): list<SinkInterface>

Returns list``<SinkInterface>