Skip to content

Log

Static facade for the logging subsystem: configuration (called in index.php before Kernel::run()) and logger acquisition (used everywhere else).

Configuration example (index.php): use Quiote\Logging{Log, Level}; use Quiote\Logging\Sink\JsonStdoutSink; Log::setDefaultLevel(Level::Info); Log::setLevels([‘Quiote’ => Level::Warning, ‘App.Orders’ => Level::Debug]); Log::addSink(new JsonStdoutSink(Level::Info)); Acquisition: $log = Log::for($this); // category from the class FQCN (dot-normalized) $log = Log::create(‘Quiote.Routing’); All calls delegate to LogRegistry, so the DI-registered LoggerFactory and this facade share one configuration.

final class Log

SourceLogging/Log.php
MethodDescription
addSink(SinkInterface $sink): voidAppends a sink to the process-global list of log destinations.
create(string $category): CategoryLoggerThe logger for an explicit dotted category, e.g.
[`for(objectstring $classOrObject): CategoryLogger`](#for)
normalizeCategory(string $fqcn): stringNormalize a class name to a dotted category (leading separators stripped, "" -> ”.”).
reset(): voidRestores the logging subsystem to its unconfigured state.
setDefaultLevel(Level $level): voidSets the minimum level for every category without a more specific rule.
setLevel(string $categoryPrefix, Level $level): voidSets the minimum level for one dotted category prefix, e.g.
setLevels(array<string, Level> $map): void

public static function addSink(SinkInterface $sink): void

Appends a sink to the process-global list of log destinations.

Sinks accumulate rather than replace, and each applies its own minimum level on top of the category threshold. With no sink registered, records are discarded after level resolution.

ParameterTypeDescription
$sinkSinkInterface

public static function create(string $category): CategoryLogger

The logger for an explicit dotted category, e.g.

Log::create(self::class) from a static method.

Loggers are cached per category and shared by all call sites using it, so calling this repeatedly is cheap and does not allocate. Unlike Log::for(), the category is taken verbatim — pass an already-dotted name.

ParameterTypeDescription
$categorystring

Returns CategoryLogger

public static function for(object|string $classOrObject): CategoryLogger

Category logger for a class or object; the category is the FQCN with namespace separators normalized to dots (so config prefixes like “App.Orders” match “App\Orders\OrderService”).

ParameterTypeDescription
$classOrObject`object““string`

Returns CategoryLogger

public static function normalizeCategory(string $fqcn): string

Normalize a class name to a dotted category (leading separators stripped, "" -> ”.”).

ParameterTypeDescription
$fqcnstring

Returns string

public static function reset(): void

Restores the logging subsystem to its unconfigured state.

Drops the registry’s levels and sinks, clears any active LogContext scopes, and empties this facade’s logger cache so the next acquisition builds a logger against the new configuration. For test isolation and reconfiguration; not used on the request path.

public static function setDefaultLevel(Level $level): void

Sets the minimum level for every category without a more specific rule.

Delegates to LogRegistry, whose memoized per-category thresholds are invalidated, so loggers already handed out pick the change up. Configuration belongs at worker startup (index.php, before Kernel::run()), not per request.

ParameterTypeDescription
$levelLevel

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

Sets the minimum level for one dotted category prefix, e.g.

Quiote.Routing.

A prefix matches a category exactly or on a dot boundary, and the longest matching prefix wins over both shorter ones and the default level. Delegates to LogRegistry, invalidating its resolved-threshold memo.

ParameterTypeDescription
$categoryPrefixstring
$levelLevel

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

category-prefix => Level

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