2018-05-26 17:30:56 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @file logger.php
|
|
|
|
* @date 2018-05-27
|
|
|
|
* @author Go Namhyeon <gnh1201@gmail.com>
|
2018-05-26 17:35:32 +00:00
|
|
|
* @brief Logger module for ReasonableFramework
|
2018-05-26 17:30:56 +00:00
|
|
|
*/
|
|
|
|
|
2019-02-26 05:40:03 +00:00
|
|
|
if(!check_function_exists("write_visit_log")) {
|
2019-05-20 08:19:05 +00:00
|
|
|
function write_visit_log() {
|
|
|
|
$fw = false;
|
2019-05-25 17:51:13 +00:00
|
|
|
$data = "";
|
2019-05-25 17:33:30 +00:00
|
|
|
|
2019-05-20 08:19:05 +00:00
|
|
|
if(loadHelper("networktool")) {
|
2019-05-27 07:35:15 +00:00
|
|
|
$event = get_network_event();
|
|
|
|
|
2019-05-27 08:16:04 +00:00
|
|
|
if(loadHelper("catsplit.format")) {
|
|
|
|
$data = catsplit_encode($event);
|
2019-05-25 17:33:30 +00:00
|
|
|
} else {
|
2019-05-27 08:16:04 +00:00
|
|
|
$data = json_encode($event);
|
2019-05-25 17:33:30 +00:00
|
|
|
}
|
|
|
|
|
2019-05-20 08:19:05 +00:00
|
|
|
$fw = append_storage_file($data, array(
|
|
|
|
"storage_type" => "logs",
|
|
|
|
"filename" => "network.log",
|
|
|
|
"chmod" => 0644,
|
2019-05-25 17:43:28 +00:00
|
|
|
"nl" => "<",
|
2019-05-20 08:19:05 +00:00
|
|
|
));
|
|
|
|
}
|
2018-09-28 06:38:18 +00:00
|
|
|
|
2019-05-20 08:19:05 +00:00
|
|
|
return $fw;
|
|
|
|
}
|
2018-09-29 21:18:44 +00:00
|
|
|
}
|
2019-05-25 17:43:28 +00:00
|
|
|
|
2019-02-26 05:40:03 +00:00
|
|
|
if(!check_function_exists("write_common_log")) {
|
2019-05-25 17:51:13 +00:00
|
|
|
function write_common_log($msg, $type="None", $networks="") {
|
|
|
|
$fw = false;
|
|
|
|
|
|
|
|
$data = implode("\t", array(get_current_datetime(), $type, $msg));
|
|
|
|
$fw = append_storage_file($data, array(
|
2019-05-20 08:19:05 +00:00
|
|
|
"storage_type" => "logs",
|
|
|
|
"filename" => "common.log",
|
|
|
|
"chmod" => 0644,
|
2019-05-25 17:43:28 +00:00
|
|
|
"nl" => "<",
|
2019-05-20 08:19:05 +00:00
|
|
|
));
|
2019-05-25 17:51:13 +00:00
|
|
|
|
|
|
|
// send to networks
|
|
|
|
$_networks = explode(",", $networks);
|
|
|
|
if(loadHelper("webhooktool")) {
|
|
|
|
foreach($_networks as $n) {
|
|
|
|
@send_web_hook($data, $n);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $fw;
|
2019-05-20 08:19:05 +00:00
|
|
|
}
|
2018-05-26 17:30:56 +00:00
|
|
|
}
|