]> source.dussan.org Git - nextcloud-server.git/commitdiff
let admin specify timezone for log file entries
authorBjoern Schiessle <schiessle@owncloud.com>
Mon, 7 Oct 2013 13:34:48 +0000 (15:34 +0200)
committerBjoern Schiessle <schiessle@owncloud.com>
Mon, 7 Oct 2013 13:34:48 +0000 (15:34 +0200)
config/config.sample.php
lib/private/log/owncloud.php

index 29085af4716240f866ad22087180fc86cab2edda..a9b868ca9cf92decbe49f9544741b2383c4e56db 100644 (file)
@@ -141,6 +141,9 @@ $CONFIG = array(
 /* date format to be used while writing to the owncloud logfile */
 'logdateformat' => 'F d, Y H:i:s',
 
+/* timezone used while writing to the owncloud logfile (default: UTC) */
+'logtimezone' => 'Europe/Berlin',
+
 /* Append all database queries and parameters to the log file.
  (watch out, this option can increase the size of your log file)*/
 "log_query" => false,
index d16b9537a1658ca4f9835494e2d9265433dd0b41..528c6bc38beed7eeb2ed5505b5815ef1c2cf5aa1 100644 (file)
@@ -50,9 +50,11 @@ class OC_Log_Owncloud {
                $minLevel=min(OC_Config::getValue( "loglevel", OC_Log::WARN ), OC_Log::ERROR);
                if($level>=$minLevel) {
                        // default to ISO8601
-                       $format = OC_Config::getValue('logdateformat', 'c');
-                       $time = date($format, time());
-                       $entry=array('app'=>$app, 'message'=>$message, 'level'=>$level, 'time'=> $time);
+                       $format = OC_Config::getValue('logdateformat', 'Y-m-d H:i:s');
+                       $logtimezone=OC_Config::getValue( "logtimezone", 'UTC' );
+                       $timezone = new DateTimeZone($logtimezone);
+                       $time = new DateTime(null, $timezone);
+                       $entry=array('app'=>$app, 'message'=>$message, 'level'=>$level, 'time'=> $time->format($format));
                        $handle = @fopen(self::$logFile, 'a');
                        if ($handle) {
                                fwrite($handle, json_encode($entry)."\n");