diff options
author | Björn Schießle <bjoern@schiessle.org> | 2013-10-08 09:27:13 -0700 |
---|---|---|
committer | Björn Schießle <bjoern@schiessle.org> | 2013-10-08 09:27:13 -0700 |
commit | 76bdd6bc81bea48ba07d0cdd2a2496a911b914c7 (patch) | |
tree | c26ebc0427f78355dfa3ea189363e7db83dfbf00 | |
parent | 92d9263e24e226ee48d9a337660d227b0c8a9714 (diff) | |
parent | 6a411833b9167278aa5667412ee96c30e87f8241 (diff) | |
download | nextcloud-server-76bdd6bc81bea48ba07d0cdd2a2496a911b914c7.tar.gz nextcloud-server-76bdd6bc81bea48ba07d0cdd2a2496a911b914c7.zip |
Merge pull request #5173 from owncloud/set_timezone_for_log
let admin specify timezone for log file entries
-rw-r--r-- | config/config.sample.php | 3 | ||||
-rw-r--r-- | lib/private/log/owncloud.php | 8 |
2 files changed, 8 insertions, 3 deletions
diff --git a/config/config.sample.php b/config/config.sample.php index 29085af4716..a9b868ca9cf 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -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, diff --git a/lib/private/log/owncloud.php b/lib/private/log/owncloud.php index d16b9537a16..528c6bc38be 100644 --- a/lib/private/log/owncloud.php +++ b/lib/private/log/owncloud.php @@ -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"); |