Skip to content

Commit

Permalink
Add the timezone in the the \DateTime constructor. While the DateTime…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
rande committed Oct 24, 2012
1 parent 023b31a commit 5e0fabe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Monolog/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public function addRecord($level, $message, array $context = array())
'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
Expand Down Expand Up @@ -339,7 +339,7 @@ public function isHandling($level)
'level' => $level,
'level_name' => static::getLevelName($level),
'channel' => $this->name,
'datetime' => new \DateTime(),
'datetime' => new \DateTime('now', static::$timezone),
'extra' => array(),
);

Expand Down

0 comments on commit 5e0fabe

Please sign in to comment.