Monolog log registry.
More...
Monolog log registry.
Allows to get Logger
instances in the global scope via static method calls on this class.
$application = new Monolog('application'); $api = new Monolog('api');
Monolog::addLogger($application); Monolog::addLogger($api);
function testLogger() { Monolog::api()->addError('Sent to $api Logger instance'); Monolog::application()->addError('Sent to $application Logger instance'); }
- Author
- Tomas Tatarko tomas.nosp@m.@tat.nosp@m.arko..nosp@m.sk
Definition at line 38 of file Registry.php.
◆ __callStatic()
static Monolog\Registry::__callStatic |
( |
|
$name, |
|
|
|
$arguments |
|
) |
| |
|
static |
Gets Logger instance from the registry via static method call.
- Parameters
-
string | $name | Name of the requested Logger instance |
array | $arguments | Arguments passed to static method call |
- Exceptions
-
Definition at line 130 of file Registry.php.
132 return self::getInstance($name);
◆ addLogger()
static Monolog\Registry::addLogger |
( |
Logger |
$logger, |
|
|
|
$name = null , |
|
|
|
$overwrite = false |
|
) |
| |
|
static |
Adds new logging channel to the registry.
- Parameters
-
Logger | $logger | Instance of the logging channel |
string | null | $name | Name of the logging channel ($logger->getName() by default) |
bool | $overwrite | Overwrite instance in the registry if the given name already exists? |
- Exceptions
-
Definition at line 55 of file Registry.php.
References Monolog\Logger\getName().
57 $name = $name ?: $logger->getName();
59 if (isset(self::$loggers[$name]) && !$overwrite) {
63 self::$loggers[$name] = $logger;
◆ clear()
static Monolog\Registry::clear |
( |
| ) |
|
|
static |
Clears the registry.
Definition at line 101 of file Registry.php.
References array.
103 self::$loggers =
array();
Create styles array
The data for the language used.
◆ getInstance()
static Monolog\Registry::getInstance |
( |
|
$name | ) |
|
|
static |
Gets Logger instance from the registry.
- Parameters
-
string | $name | Name of the requested Logger instance |
- Exceptions
-
Definition at line 113 of file Registry.php.
115 if (!isset(self::$loggers[$name])) {
119 return self::$loggers[$name];
◆ hasLogger()
static Monolog\Registry::hasLogger |
( |
|
$logger | ) |
|
|
static |
Checks if such logging channel exists by name or instance.
- Parameters
-
string | Logger | $logger | Name or logger instance |
Definition at line 71 of file Registry.php.
73 if ($logger instanceof Logger) {
74 $index = array_search($logger, self::$loggers,
true);
76 return false !== $index;
78 return isset(self::$loggers[$logger]);
◆ removeLogger()
static Monolog\Registry::removeLogger |
( |
|
$logger | ) |
|
|
static |
Removes instance from registry by name or instance.
- Parameters
-
string | Logger | $logger | Name or logger instance |
Definition at line 87 of file Registry.php.
89 if ($logger instanceof Logger) {
90 if (
false !== ($idx = array_search($logger, self::$loggers,
true))) {
91 unset(self::$loggers[$idx]);
94 unset(self::$loggers[$logger]);
◆ $loggers
Monolog\Registry::$loggers = array() |
|
staticprivate |
The documentation for this class was generated from the following file:
- libs/composer/vendor/monolog/monolog/src/Monolog/Registry.php