Download the PHP package eonx-com/easy-logging without Composer
On this page you can find all versions of the php package eonx-com/easy-logging. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package easy-logging
---eonx_docs--- title: Introduction weight: 0 ---eonx_docs---
This package allows you to create and configure Monolog Loggers in centralised and reusable way:
- Configure channels using PHP
- Control Handlers and Processors order
- Integration with popular frameworks (e.g. Laravel, Symfony)
- Discover Handlers and Processors automatically in your application
Require package (Composer)
The recommended way to install this package is to use Composer:
Usage
Here is a simple example on how to use the LoggerFactoryInterface to create loggers:
Usage in Framework
The different integrations provided by this package will by default register the logger for your default channel in the service container under the following service ids:
Psr\Log\LoggerInterfacelogger
You can then use dependency injection anywhere you like!
Thanks to Autowiring via setters in Symfony, you can use \EonX\EasyLogging\Logger\LoggerAwareTrait
to simplify the injection of Psr\Log\LoggerInterface.
Logger Configuration
The LoggerFactoryInterface allows you to set different collections of "config providers", each config can define:
- channels: if defined the config will be applied only to given channels, if
nullthe config will be applied to all channels - priority: define the order each config must be set on the logger instance, higher the priority later the config will be added to the logger instance
HandlerConfig
The HandlerConfigInterface allows you to configure \Monolog\Handler\HandlerInterface to be set loggers created by
the factory. Like other configs, it allows you to specify a list of channels this handler is for and, also a priority
to control when the handler must be executed.
To tell the logger factory about your HandlerConfigInterface, you must use a HandlerConfigProviderInterface. The
logger factory accepts a collection of providers via the setHandlerConfigProviders() method:
Here is a simple example of a HandlerConfigProviderInterface to register a StreamHandler:
ProcessorConfig
The ProcessorConfigInterface allows you to configure \Monolog\Processor\ProcessorInterface to be set loggers created
by the factory. Like other configs, it allows you to specify a list of channels this handler is for and, also a priority
to control when the handler must be executed.
To tell the logger factory about your ProcessorConfigInterface, you must use a ProcessorConfigProviderInterface. The
logger factory accepts a collection of providers via the setProcessorConfigProviders() method:
Here is a simple example of a ProcessorConfigProviderInterface to register a TagProcessor:
LoggerConfigurator
The \Monolog\Logger class has methods allowing you to configure it even more (e.g. using microseconds). To deal with
that, the logger factory accepts a collection of LoggerConfiguratorInterface.
To tell the logger factory about your LoggerConfiguratorInterface, you must call the setLoggerConfigurators() method:
Here is a simple example of a LoggerConfiguratorInterface to use microseconds:
All versions of easy-logging with dependencies
eonx-com/easy-utils Version ^6.28
monolog/monolog Version ^3.9
symfony/config Version ^7.2
symfony/dependency-injection Version ^7.2
symfony/http-kernel Version ^7.2
symfony/service-contracts Version ^3.5