summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Prodromou <evan@prodromou.name>2008-07-12 11:15:21 -0400
committerEvan Prodromou <evan@prodromou.name>2008-07-12 11:15:21 -0400
commita25f5010e682a0fc950e2ef2476af7b631ada5bf (patch)
tree1e64735c09d13c0b752667f52182cc26d34cb2f2
parent74c3b9de236b61e731cbdca6564fba773b34a23b (diff)
add the logfile entry to common, a little recoding in common_log
darcs-hash:20080712151521-84dde-a81c53bacbe15e77b70fc460ad9143e7e4f8402c.gz
-rw-r--r--lib/common.php1
-rw-r--r--lib/util.php22
2 files changed, 14 insertions, 9 deletions
diff --git a/lib/common.php b/lib/common.php
index 15ba1ed2a..9d321f27d 100644
--- a/lib/common.php
+++ b/lib/common.php
@@ -40,6 +40,7 @@ $config =
'server' => 'localhost',
'theme' => 'default',
'path' => '/',
+ 'logfile' => NULL,
'fancy' => false,
'email' => $_SERVER['SERVER_ADMIN'],
'broughtby' => NULL,
diff --git a/lib/util.php b/lib/util.php
index 8b17d873b..432528074 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -1063,15 +1063,19 @@ function common_ensure_syslog() {
}
function common_log($priority, $msg, $filename=NULL) {
- common_ensure_syslog();
- syslog($priority, $msg);
- global $config;
- $log = fopen($config['site']['logfile'], "a");
- if ($log) {
- $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";
- fwrite($log, $output);
- fclose($log);
+ $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";
+ fwrite($log, $output);
+ fclose($log);
+ }
+ } else {
+ common_ensure_syslog();
+ syslog($priority, $msg);
}
}