vakata/log

A file logger class

3.0.2 2016-10-27 11:39 UTC

This package is auto-updated.

Last update: 2024-11-10 06:33:20 UTC


README

Latest Version on Packagist Software License Build Status Code Climate Tests Coverage

A file logger class.

Install

Via Composer

$ composer require vakata/log

Usage

// create an instance
// by default all error levels are logged to the default "error_log" location
$log = new \vakata\log\Log();
// log a message with some params
$log->debug('Just some info', ['context'=>'params']);
// add some additional context for all future calls
$log->addContext(['context'=>'for all future logs']);
// directly logging exceptions works too
try {
    throw new Exception('Some exception');
}
catch (\Exception $e) {
    $log->error($e);
}

// you can optionally make sure only certain error levels are logged
// and also specify a file for the log
$log = new \vakata\log\Log(
    \vakata\log\Log::ALL ^ \vakata\log\Log::DEBUG, // we log everything but debug
    __DIR__ . '/path/to.log'
);

Read more in the API docs

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email github@vakata.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.