How to use KLogger?

The general handler that I used

<?php
function error_msg($err_type,$err_msg,$err_file,$err_line)
{
$fh=fopen("error/errorlog.txt","a");
$date1=date("Y-m-d H:i:s");
$er="
===============================================================================================================
"."
Error: Type: ".$err_type."Message: ".$err_msg."ErrorFile: ".$err_file."Errorline: ".$err_line."Time: ".$date1.
"
===============================================================================================================
";
fwrite($fh,$er);
fclose($fh);
}
set_error_handler("error_msg");
?>

These log error codes are excellent. Since I use the framework, I cannot use these codes. therefore I use KLogger. KLogger logs my error perfectly, but also displays the error on the front screen for the user.

How to log an error using KLogger. If anyone uses this KLogger Help me use with simple examples.

+3
source share
1 answer

Just do something like:

require_once 'KLogger.php';

$log = KLogger::instance('/var/log/');
$log->logInfo('Returned a million search results');
$log->logFatal('Oh dear.');

# Output will log to the path you specified, at log_[current-date].txt

It is insanely simple. Read the docs on GitHub

PS, I wrote KLogger.

+14
source

Source: https://habr.com/ru/post/1780697/


All Articles