From 8c8edfe44e5396295b99a68d5fe99032a492563b Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Thu, 23 Jan 2020 21:43:58 +0900 Subject: [PATCH] Update logger.php --- system/logger.php | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/system/logger.php b/system/logger.php index 359369a..7cb0277 100644 --- a/system/logger.php +++ b/system/logger.php @@ -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; } }