From 5e0fabeb0def6bb2ccc94a0226e8810aedee9ae3 Mon Sep 17 00:00:00 2001 From: Thomas Rabaix Date: Wed, 24 Oct 2012 13:32:05 +0200 Subject: [PATCH] Add the timezone in the the \DateTime constructor. While the DateTime object is initialized without the DateTimeZone instance, the underline library execute a stat('.../Europe/Paris') to check if the OS knows the timezone. This will improve performance on long run process by avoiding unless i/o calls. --- src/Monolog/Logger.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Monolog/Logger.php b/src/Monolog/Logger.php index 871eccac..412c506f 100644 --- a/src/Monolog/Logger.php +++ b/src/Monolog/Logger.php @@ -191,7 +191,7 @@ class Logger 'level' => $level, 'level_name' => static::getLevelName($level), 'channel' => $this->name, - 'datetime' => \DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true)))->setTimeZone(static::$timezone), + 'datetime' => \DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true)), static::$timezone)->setTimezone(static::$timezone), 'extra' => array(), ); // check if any handler will handle this message @@ -339,7 +339,7 @@ class Logger 'level' => $level, 'level_name' => static::getLevelName($level), 'channel' => $this->name, - 'datetime' => new \DateTime(), + 'datetime' => new \DateTime('now', static::$timezone), 'extra' => array(), );