Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use KLogger?

Tags:

php

frameworks

Common handler 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 codes Log error perfectly. Since i am using framework i cant use this codes. so i am using KLogger. KLogger perfectly logs my error but it also display error in front screen to user.

How to log error using KLogger If any one use this KLogger Help me how to use with simple examples.

like image 482
Mohan Ram Avatar asked Dec 09 '22 12:12

Mohan Ram


1 Answers

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's crazy simple. Read the docs at GitHub

PS, I wrote KLogger.

like image 191
Kenny Avatar answered Dec 23 '22 00:12

Kenny