Update logger.php

This commit is contained in:
Namhyeon Go 2020-01-23 21:43:58 +09:00 committed by GitHub
parent 61d926bd68
commit 8c8edfe44e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,8 +6,8 @@
* @brief Logger module for ReasonableFramework
*/
if(!check_function_exists("write_log_to_file")) {
function write_log_to_file($data, $filename) {
if(!check_function_exists("append_log_to_file")) {
function append_log_to_file($data, $filename) {
return append_storage_file($data, array(
"storage_type" => "logs",
"filename" => $filename,
@ -30,7 +30,7 @@ if(!check_function_exists("write_visit_log")) {
$data = json_encode($nevt);
}
$fw = write_log_to_file($data, "network.log");
$fw = append_log_to_file($data, "network.log");
}
return $fw;
@ -38,18 +38,15 @@ if(!check_function_exists("write_visit_log")) {
}
if(!check_function_exists("write_common_log")) {
function write_common_log($msg, $type="None", $networks="") {
function write_common_log($message, $component="None", $program="") {
$fw = false;
$data = implode("\t", array(get_current_datetime(), $type, $msg));
$fw = write_log_to_file($data, "common.log");
$data = implode("\t", array(get_current_datetime(), $component, $message));
$fw = append_log_to_file($data, "common.log");
// send to networks
$_networks = explode(",", $networks);
if(loadHelper("webhooktool")) {
foreach($_networks as $n) {
@send_web_hook($data, $n);
}
// if enabled RFC3164 remote debugging
if(loadHelper("rfc3164.proto")) {
rfc3164_send_message($message, $component, $program);
}
return $fw;
@ -57,10 +54,21 @@ if(!check_function_exists("write_common_log")) {
}
if(!check_function_exists("write_debug_log")) {
function write_debug_log($msg, $type="None") {
if(APP_DEVELOPMENT !== false) {
$data = implode("\t", array(get_current_datetime(), $type, $msg));
return write_log_to_file($data, "debug.log");
function write_debug_log($message, $component="Debug", $program="") {
$fw = false;
// if not debug mode
if(APP_DEVELOPMENT === false) return $fw;
// if debug mode
$data = implode("\t", array(get_current_datetime(), $type, $message));
$fw = append_log_to_file($data, "debug.log");
// if enabled RFC3164 remote debugging
if(loadHelper("rfc3164.proto")) {
rfc3164_send_message($message, $component, $program);
}
return $fw;
}
}