]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
add the logfile entry to common, a little recoding in common_log
authorEvan Prodromou <evan@prodromou.name>
Sat, 12 Jul 2008 15:15:21 +0000 (11:15 -0400)
committerEvan Prodromou <evan@prodromou.name>
Sat, 12 Jul 2008 15:15:21 +0000 (11:15 -0400)
darcs-hash:20080712151521-84dde-a81c53bacbe15e77b70fc460ad9143e7e4f8402c.gz

lib/common.php
lib/util.php

index 15ba1ed2a7ee6522d470038b8f99d5767fa9c79c..9d321f27d4800170d82b216306d828727ea37ebc 100644 (file)
@@ -40,6 +40,7 @@ $config =
                          'server' => 'localhost',
                          'theme' => 'default',
                          'path' => '/',
+                         'logfile' => NULL,
                          'fancy' => false,
                          'email' => $_SERVER['SERVER_ADMIN'],
                          'broughtby' => NULL,
index 8b17d873b0d7335139fb3802945fb336968e3ef0..432528074bf95f220296275d8e3b676da09fd084 100644 (file)
@@ -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);
        }
 }