reasonableframework/system/logger.php

67 lines
1.7 KiB
PHP
Raw Normal View History

<?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
*/
2019-12-05 10:41:58 +00:00
if(!check_function_exists("write_log_to_file")) {
function write_log_to_file($data, $filename) {
return append_storage_file($data, array(
"storage_type" => "logs",
"filename" => $filename,
"chmod" => 0644,
"nl" => "<",
));
}
}
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-12-05 10:41:58 +00:00
2019-05-25 17:51:13 +00:00
$data = "";
2019-05-20 08:19:05 +00:00
if(loadHelper("networktool")) {
2019-12-05 10:41:58 +00:00
$nevt = get_network_event();
2019-05-27 08:16:04 +00:00
if(loadHelper("catsplit.format")) {
2019-12-05 10:41:58 +00:00
$data = catsplit_encode($nevt);
2019-05-25 17:33:30 +00:00
} else {
2019-12-05 10:41:58 +00:00
$data = json_encode($nevt);
2019-05-25 17:33:30 +00:00
}
2019-12-05 10:41:58 +00:00
$fw = write_log_to_file($data, "network.log");
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));
2019-12-05 10:41:58 +00:00
$fw = write_log_to_file($data, "common.log");
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
}
}
2019-12-05 10:41:58 +00:00
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");
}
}
}