Update logger.php

This commit is contained in:
Namhyeon Go 2019-05-26 02:51:13 +09:00 committed by GitHub
parent 459838c4e8
commit ad840ce526
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,14 +9,14 @@
if(!check_function_exists("write_visit_log")) { if(!check_function_exists("write_visit_log")) {
function write_visit_log() { function write_visit_log() {
$fw = false; $fw = false;
$msg = ""; $data = "";
$event = get_network_event(); $event = get_network_event();
if(loadHelper("networktool")) { if(loadHelper("networktool")) {
if(loadHelper("rsf.format")) { if(loadHelper("rsf.format")) {
$msg = get_rsf_encoded($event); $data = get_rsf_encoded($event);
} else { } else {
$msg = json_encode(get_network_event()); $data = json_encode(get_network_event());
} }
$fw = append_storage_file($data, array( $fw = append_storage_file($data, array(
@ -32,12 +32,25 @@ 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) { function write_common_log($msg, $type="None", $networks="") {
return append_storage_file($msg, array( $fw = false;
$data = implode("\t", array(get_current_datetime(), $type, $msg));
$fw = append_storage_file($data, array(
"storage_type" => "logs", "storage_type" => "logs",
"filename" => "common.log", "filename" => "common.log",
"chmod" => 0644, "chmod" => 0644,
"nl" => "<", "nl" => "<",
)); ));
// send to networks
$_networks = explode(",", $networks);
if(loadHelper("webhooktool")) {
foreach($_networks as $n) {
@send_web_hook($data, $n);
}
}
return $fw;
} }
} }