Improved log handling
This commit is contained in:
@@ -32,4 +32,9 @@ $_config['sanity_interval']=900;
|
||||
$_config['allow_hostname_change']=false;
|
||||
// rebroadcast local transactions on each sanity
|
||||
$_config['sanity_rebroadcast_locals']=true;
|
||||
// write logs to file
|
||||
$_config['enable_logging']=false;
|
||||
// log file, should not be publicly viewable
|
||||
$_config['log_file']="/var/log/aro.log";
|
||||
|
||||
?>
|
||||
|
||||
@@ -21,10 +21,21 @@ function api_echo($data){
|
||||
}
|
||||
// log function, shows only in cli atm
|
||||
function _log($data){
|
||||
$date=date("[Y-m-d H:s:]");
|
||||
$trace=debug_backtrace();
|
||||
$location=$trace[1]['class'].'->'.$trace[1]['function'].'()';
|
||||
if(php_sapi_name() === 'cli') echo "$date [$location] $data\n";
|
||||
$date=date("[Y-m-d H:s:]");
|
||||
$trace=debug_backtrace();
|
||||
$loc=count($trace)-1;
|
||||
$file=substr($trace[$loc]['file'],strrpos($trace[$loc]['file'],"/")+1);
|
||||
|
||||
$res="$date ".$file.":".$trace[$loc]['line'];
|
||||
|
||||
if(!empty($trace[$loc]['class'])) $res.="---".$trace[$loc]['class'];
|
||||
if(!empty($trace[$loc]['function'])&&$trace[$loc]['function']!='_log') $res.='->'.$trace[$loc]['function'].'()';
|
||||
$res.=" $data \n";
|
||||
if(php_sapi_name() === 'cli') echo $res;
|
||||
global $_config;
|
||||
if($_config['enable_logging']==true){
|
||||
@file_put_contents($_config['log_file'],$res, FILE_APPEND);
|
||||
}
|
||||
}
|
||||
|
||||
// converts PEM key to hex
|
||||
|
||||
Reference in New Issue
Block a user