/CLogger

Primary LanguagePHPMIT LicenseMIT

CLogger

A simple class that logs your errors to files.

How to install

This repo is avaiable through packagist with the command:

composer require krysvac/clogger

How to use

You will need to call these static functions to initialize the class.

// A folder called 'log' will be created in your output folder.
// This is where all the files will be created in.
CLogger::setOutputDir("/path/to/your/output/folder");

// Initializes class
CLogger::init();

This CLogger class uses set_error_handler() to write the errors on the file. It's recommended to initialize the class as early as possible

Once initialized, all errors will be written to a file To trigger an error use trigger_error().

trigger_error("This is a warning!", E_USER_WARNING);

Also note that this function will not use error_reporting() to set which errors to display, instead you need to set it yourself.
Example:

error_reporting(E_ALL);
CLogger::init();

License

This code is open-sourced software licensed under the MIT license.

Build Status Scrutinizer Code Quality Code Coverage