Update logger.php
This commit is contained in:
parent
61d926bd68
commit
8c8edfe44e
|
@ -6,8 +6,8 @@
|
||||||
* @brief Logger module for ReasonableFramework
|
* @brief Logger module for ReasonableFramework
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if(!check_function_exists("write_log_to_file")) {
|
if(!check_function_exists("append_log_to_file")) {
|
||||||
function write_log_to_file($data, $filename) {
|
function append_log_to_file($data, $filename) {
|
||||||
return append_storage_file($data, array(
|
return append_storage_file($data, array(
|
||||||
"storage_type" => "logs",
|
"storage_type" => "logs",
|
||||||
"filename" => $filename,
|
"filename" => $filename,
|
||||||
|
@ -30,7 +30,7 @@ if(!check_function_exists("write_visit_log")) {
|
||||||
$data = json_encode($nevt);
|
$data = json_encode($nevt);
|
||||||
}
|
}
|
||||||
|
|
||||||
$fw = write_log_to_file($data, "network.log");
|
$fw = append_log_to_file($data, "network.log");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $fw;
|
return $fw;
|
||||||
|
@ -38,18 +38,15 @@ if(!check_function_exists("write_visit_log")) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!check_function_exists("write_common_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;
|
$fw = false;
|
||||||
|
|
||||||
$data = implode("\t", array(get_current_datetime(), $type, $msg));
|
$data = implode("\t", array(get_current_datetime(), $component, $message));
|
||||||
$fw = write_log_to_file($data, "common.log");
|
$fw = append_log_to_file($data, "common.log");
|
||||||
|
|
||||||
// send to networks
|
// if enabled RFC3164 remote debugging
|
||||||
$_networks = explode(",", $networks);
|
if(loadHelper("rfc3164.proto")) {
|
||||||
if(loadHelper("webhooktool")) {
|
rfc3164_send_message($message, $component, $program);
|
||||||
foreach($_networks as $n) {
|
|
||||||
@send_web_hook($data, $n);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $fw;
|
return $fw;
|
||||||
|
@ -57,10 +54,21 @@ if(!check_function_exists("write_common_log")) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!check_function_exists("write_debug_log")) {
|
if(!check_function_exists("write_debug_log")) {
|
||||||
function write_debug_log($msg, $type="None") {
|
function write_debug_log($message, $component="Debug", $program="") {
|
||||||
if(APP_DEVELOPMENT !== false) {
|
$fw = false;
|
||||||
$data = implode("\t", array(get_current_datetime(), $type, $msg));
|
|
||||||
return write_log_to_file($data, "debug.log");
|
// 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user