cherry-project / logger
Cherry-project logger
v1.0.0
2019-02-28 12:50 UTC
Requires
- php: >=5.6.0
- phpunit/phpunit: ^8.0
This package is auto-updated.
Last update: 2024-11-29 06:09:46 UTC
README
The Cherry-project logger
Including
Install from composer composer require cherry-project/logger
Include Autoloader in your main file (Ex.: index.php)
require_once __DIR__ . '/vendor/autoload.php';
Import class
use Cherry\Logger;
Set logs directory
define('LOGS_DIR', __DIR__ . '/var/log');
Crete class new object
Logger class takes two arguments:
- Log Name, the logs filename {LogName}.log (Default 'app').
- Logs Directory(Default '/var/log').
$logger = new Logger('app-logs', LOGS_DIR);
Logger methods
The logger has 4 Log types:
- info();
- warning();
- error();
- debug()
and additional methods:
- clear() clear logs in current instance;
- count() get logs count in current instance;
Call methods
$logger->info('Info Message'); $logger->warning('Warning Message'); $logger->error('Error Message'); $logger->debug('Debug Message');
Also you can call more then one method from one object:
$logger->info('Info Message 2') ->warning('Warning Message 2') ->error('Error Message 2') ->debug('Debug Message 2');
If you need logs count in current instance, you might use count() method:
echo $logger->count();
You can clear all the logs in the current instance using the clear() method:
$logger->clear();
2019 © Cherry-project