Skip to content

cherry-framework/logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cherry-logger

The Cherry-project logger

GitHub license

GitHub release

Packagist Version


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