forked from GNUsocial/gnu-social
extract log-line formatting to its own function
This commit is contained in:
parent
cfd2548923
commit
9f079764aa
11
lib/util.php
11
lib/util.php
@ -1104,15 +1104,20 @@ function common_ensure_syslog()
|
||||
}
|
||||
}
|
||||
|
||||
function common_log_line($priority, $msg)
|
||||
{
|
||||
static $syslog_priorities = array('LOG_EMERG', 'LOG_ALERT', 'LOG_CRIT', 'LOG_ERR',
|
||||
'LOG_WARNING', 'LOG_NOTICE', 'LOG_INFO', 'LOG_DEBUG');
|
||||
return date('Y-m-d H:i:s') . ' ' . $syslog_priorities[$priority] . ': ' . $msg . "\n";
|
||||
}
|
||||
|
||||
function common_log($priority, $msg, $filename=null)
|
||||
{
|
||||
$logfile = common_config('site', 'logfile');
|
||||
if ($logfile) {
|
||||
$log = fopen($logfile, "a");
|
||||
if ($log) {
|
||||
static $syslog_priorities = array('LOG_EMERG', 'LOG_ALERT', 'LOG_CRIT', 'LOG_ERR',
|
||||
'LOG_WARNING', 'LOG_NOTICE', 'LOG_INFO', 'LOG_DEBUG');
|
||||
$output = date('Y-m-d H:i:s') . ' ' . $syslog_priorities[$priority] . ': ' . $msg . "\n";
|
||||
$output = common_log_line($priority, $msg);
|
||||
fwrite($log, $output);
|
||||
fclose($log);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user