Cherry-project logger

v1.0.0 2019-02-28 12:50 UTC

This package is auto-updated.

Last update: 2022-04-29 00:57:18 UTC


The Cherry-project logger

GitHub license

GitHub release

Packagist Version


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:


2019 © Cherry-project