enlitepro / enlite-monolog
Monolog integration to Laminas
Installs: 582 402
Dependents: 5
Suggesters: 1
Security: 0
Stars: 17
Watchers: 4
Forks: 17
Open Issues: 2
Requires
- php: ^7.1 || ^8.0
- container-interop/container-interop: ^1.0
- laminas/laminas-servicemanager: ^3
- laminas/laminas-stdlib: ^3
- monolog/monolog: ^1.3 || ^2.0
Requires (Dev)
- johnkary/phpunit-speedtrap: ^3.0
- php-parallel-lint/php-parallel-lint: ^1.3
- phpunit/phpunit: ^7.5.20 || ^8.5.2 || ^9.5.6
- squizlabs/php_codesniffer: ^3.0
README
Integration to Laminas with great logging system monolog
INSTALL
The recommended way to install is through composer from command line.
composer require enlitepro/enlite-monolog
USAGE
- Add
EnliteMonolog
to yourconfig/application.config.php
to enable module.
// usage over service locator $serviceLocator->get('EnliteMonologService')->debug('hello world'); use EnliteMonolog\Service\MonologServiceAwareInterface, EnliteMonolog\Service\MonologServiceAwareTrait; // usage in your services class MyService implements MonologServiceAwareInterface { use MonologServiceAwareTrait; public function whatever() { $this->getMonologService()->debug('hello world'); } }
- Copy the config file
config/monolog.global.php.dist
from the module to config/autoload your project.
By default it write logs to data/logs/application.log
. If you want change this behaviour, add your config following:
'EnliteMonolog' => array( 'EnliteMonologService' => array( // Logger name // 'name' => 'EnliteMonolog', // Handlers, it can be service locator alias(string) or config(array) 'handlers' => array( // by config 'default' => array( 'name' => 'Monolog\Handler\StreamHandler', 'args' => array( 'stream' => 'data/log/application.log', 'level' => \Monolog\Logger::DEBUG, 'bubble' => true ), 'formatter' => array( 'name' => 'Monolog\Formatter\LogstashFormatter', 'args' => array( 'applicationName' => 'My Application', ), ), ), // by service locator 'MyMonologHandler' ) ), // you can specify another logger // for example ChromePHPHandler 'MyChromeLogger' => array( 'name' => 'MyName', 'handlers' => array( array( 'name' => 'Monolog\Handler\ChromePHPHandler', ) ) ) ),
now you can use it
$serviceLocator->get('EnliteMonologService')->debug('hello world'); $serviceLocator->get('MyChromeLogger')->debug('hello world');
Contributing
This library attempts to comply with PSR-1, PSR-2, and PSR-4. If you notice compliance oversights, please send a patch via pull request.