Download the PHP package opxcore/log-manager without Composer
On this page you can find all versions of the php package opxcore/log-manager. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package log-manager
Log manager
Log manager is package to handle multiple loggers. All write (send or something else) logic and message formatting must be implemented in these loggers. Log manager is only resolves which logger will be used and fires log action for corresponding logger.
Each logger must implement Psr\Log\LoggerInterface .
Installing
Basic creating:
Creating with container
or
Configuring and using
Configuration array consists of three keys. Value of 'default'
must contain a name (or array of names) of logger to be
used as default logger. 'loggers'
is a set of loggers to be used keyed by name. A required parameter of each logger is
a 'driver'
containing class name of logger to be used with corresponding name (see examples below). Third additional
key 'groups'
contain array of logger groups keyed by name of group.
Log manager extends container, so loggers will be resolved by it with all
dependency injections. All loggers will be resolved on demand and instanced for future use. All parameters
except 'driver'
will be passed to logger constructor as parameters.
Additionally, you can bind custom created logger:
To get a certain logger call method
$manager->logger($name)
where $name
is name of logger to be returned. If null
given the default logger (or several loggers) will be used.
To get multiple log loggers use same method with an array of names
$manager->logger([$name1, $name2])
In both cases LoggerProxy
class with chosen loggers bindings will be returned,
so $manager->logger([$name1, $name2])->log($message)
will call log action on each of logger.
To use group logging use $manager->group($group)
or $manager->group([$group1, $group2])
. Each group will be resolved
to set of loggers and then merged together, removing duplicates.
PSR-3
Log manager implements PSR-3. So available methods are:
These methods will call corresponding method of default logger(s).
Examples
Log manager configuration:
Logger class:
Calling $manager->logger('file')
at first time will create and return LogFile class instance (for this example is
equal to new \OpxCore\Log\LogFile('/www/project/logs')
) and store it's an instance for future use. So
calling $manager->logger('file')
for second time will return same instance of logger.
For this example using
is equal to (as 'file'
set as default logger)
and equal to
All versions of log-manager with dependencies
opxcore/log-interface Version ^1.0.8
opxcore/log-manager-interface Version ^1.0.0
opxcore/container Version ^1.0.3