Logger
The Logger enables the functionality of logging messages, errors and debugging values in log files. The logger is a modified version of KLogger.
Storage path
Log files are stored at{wp-content}/wpmvc/log
folder.
Usage
Before start using the Logger, add the use
statement at the beginning of your PHP file to call it.
use WPMVC\Log;
Info
Use the static method info()
to log a message.
Log::info( 'My string message' );
Debug
Use the static method debug()
to log a variable and its value. This enables code debugging without having to break HTML design.
/** * @param string String identifier of the value to debug. * @param mixed Supported data types as value parameters are: * string, numeric and array. */ Log::debug( 'Value', $value );
Error
Use the static method error()
to log execution errors and exceptions.
// Logs errors and exception. Log::error( $exception ); // Usage in a try/catch statement. try { // { Any code here... } } catch ( Exception $e ) { Log::error( $e ); }