phlib / logger
Additional Logging Classes
Installs: 106 486
Dependents: 2
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 1
Requires
- php: ^7.3|^8
- ext-json: *
- graylog2/gelf-php: ^1.3
- psr/log: ^1 || ^2 || ^3
- symfony/console: ^2.5.12|^3|^4|^5 || ^6
Requires (Dev)
Provides
- psr/log-implementation: 1.0 || 2.0 || 3.0
README
PHP PSR-3-compatible logger
Install
Via Composer
$ composer require phlib/logger
Usage
Example config for a logger pool
$loggerConfig = [ 'default' => [ // logger config identifier, used as facility/name in log messages // multiple logger entries becomes a collection logger [ // logger type (stream, gelf...) 'type' => 'stream', // the level of log messages to include (optional) 'level' => \Psr\Log\LogLevel::ERROR, // logger specific parameters 'path' => '/var/log/my_app.log' ], [ 'type' => 'gelf', 'level' => \Psr\Log\LogLevel::INFO, // logger specific parameters 'host' => '127.0.0.1', 'port' => 12201 ] ], 'application' => 'default', // alias to another logger config 'api' => [ 'type' => 'gelf', 'host' => '127.0.0.1', 'port' => 12201 ] ];
Creation of logger pool
$loggerPool = new \Phlib\Logger\Pool( new \Phlib\Logger\Config($loggerConfig), new \Phlib\Logger\Factory() );
Get a logger instance
$applicationLogger = $loggerPool->getLogger('application'); // or $applicationLogger = $loggerPool->application; $applicationLogger->info('Logging is initialised');
License
This package is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see http://www.gnu.org/licenses/.