Documentation

Registry
in package

Monolog log registry

Allows to get Logger instances in the global scope via static method calls on this class.

$application = new Monolog\Logger('application'); $api = new Monolog\Logger('api');

Monolog\Registry::addLogger($application); Monolog\Registry::addLogger($api);

function testLogger() { Monolog\Registry::api()->addError('Sent to $api Logger instance'); Monolog\Registry::application()->addError('Sent to $application Logger instance'); }

Tags
author

Tomas Tatarko tomas@tatarko.sk

Table of Contents

Properties

$loggers  : array<string|int, Logger>
List of all loggers in the registry (by named indexes)

Methods

__callStatic()  : Logger
Gets Logger instance from the registry via static method call
addLogger()  : mixed
Adds new logging channel to the registry
clear()  : mixed
Clears the registry
getInstance()  : Logger
Gets Logger instance from the registry
hasLogger()  : mixed
Checks if such logging channel exists by name or instance
removeLogger()  : mixed
Removes instance from registry by name or instance

Properties

$loggers

List of all loggers in the registry (by named indexes)

private static array<string|int, Logger> $loggers = array()

Methods

__callStatic()

Gets Logger instance from the registry via static method call

public static __callStatic(string $name, array<string|int, mixed> $arguments) : Logger
Parameters
$name : string

Name of the requested Logger instance

$arguments : array<string|int, mixed>

Arguments passed to static method call

Tags
throws
InvalidArgumentException

If named Logger instance is not in the registry

Return values
Logger

Requested instance of Logger

addLogger()

Adds new logging channel to the registry

public static addLogger(Logger $logger[, string|null $name = null ][, bool $overwrite = false ]) : mixed
Parameters
$logger : Logger

Instance of the logging channel

$name : string|null = null

Name of the logging channel ($logger->getName() by default)

$overwrite : bool = false

Overwrite instance in the registry if the given name already exists?

Tags
throws
InvalidArgumentException

If $overwrite set to false and named Logger instance already exists

clear()

Clears the registry

public static clear() : mixed

getInstance()

Gets Logger instance from the registry

public static getInstance(string $name) : Logger
Parameters
$name : string

Name of the requested Logger instance

Tags
throws
InvalidArgumentException

If named Logger instance is not in the registry

Return values
Logger

Requested instance of Logger

hasLogger()

Checks if such logging channel exists by name or instance

public static hasLogger(string|Logger $logger) : mixed
Parameters
$logger : string|Logger

Name or logger instance

removeLogger()

Removes instance from registry by name or instance

public static removeLogger(string|Logger $logger) : mixed
Parameters
$logger : string|Logger

Name or logger instance


        
On this page

Search results