mirror of
https://github.com/Seldaek/monolog.git
synced 2025-10-21 16:46:11 +02:00
Add Logger::setTimezone()
Add a setter method to allow changing the timezone used when creating
new log records. This provides a means to correct a behavioral change
introduced by 6cbdc04
where use of the PHP runtime default timezone
provided by `date_default_timezone_get()` was introduced. In most
environments the new default behavior is preferable, but if an
application allows the default timezone to vary between requests it
causes confusing log output.
This commit is contained in:
@@ -614,4 +614,14 @@ class Logger implements LoggerInterface
|
||||
{
|
||||
return $this->addRecord(static::EMERGENCY, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the timezone to be used for the timestamp of log records.
|
||||
*
|
||||
* @param string $tz Timezone name
|
||||
*/
|
||||
public static function setTimezone($tz)
|
||||
{
|
||||
self::$timezone = new \DateTimeZone($tz);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user