summaryrefslogtreecommitdiff
path: root/lib/util.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@controlyourself.ca>2009-06-28 16:38:27 -0400
committerEvan Prodromou <evan@controlyourself.ca>2009-06-28 16:38:27 -0400
commit9f079764aa945e9e126ffa41cece17bc8951fb78 (patch)
tree1d8b26e09b782cd910b3e433363d80db66a93f8f /lib/util.php
parentcfd25489235b176c33cc4104aadfe5378fffe67d (diff)
extract log-line formatting to its own function
Diffstat (limited to 'lib/util.php')
-rw-r--r--lib/util.php11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/util.php b/lib/util.php
index 469f132b8..1ae43a056 100644
--- a/lib/util.php
+++ b/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);
}