Merge pull request #5219 from owncloud/catch_wrong_timezone

catch unknown timezone and fall-back to UTC
This commit is contained in:
Björn Schießle 2013-10-09 01:59:09 -07:00
commit b4df4cc61d
1 changed files with 6 additions and 2 deletions

View File

@ -50,9 +50,13 @@ class OC_Log_Owncloud {
$minLevel=min(OC_Config::getValue( "loglevel", OC_Log::WARN ), OC_Log::ERROR); $minLevel=min(OC_Config::getValue( "loglevel", OC_Log::WARN ), OC_Log::ERROR);
if($level>=$minLevel) { if($level>=$minLevel) {
// default to ISO8601 // default to ISO8601
$format = OC_Config::getValue('logdateformat', 'Y-m-d H:i:s'); $format = OC_Config::getValue('logdateformat', 'c');
$logtimezone=OC_Config::getValue( "logtimezone", 'UTC' ); $logtimezone=OC_Config::getValue( "logtimezone", 'UTC' );
try {
$timezone = new DateTimeZone($logtimezone); $timezone = new DateTimeZone($logtimezone);
} catch (Exception $e) {
$timezone = new DateTimeZone('UTC');
}
$time = new DateTime(null, $timezone); $time = new DateTime(null, $timezone);
$entry=array('app'=>$app, 'message'=>$message, 'level'=>$level, 'time'=> $time->format($format)); $entry=array('app'=>$app, 'message'=>$message, 'level'=>$level, 'time'=> $time->format($format));
$handle = @fopen(self::$logFile, 'a'); $handle = @fopen(self::$logFile, 'a');