Set Timezone to 'UTC' for every Logger (Develop)

This commit is contained in:
Philipp Holzer 2019-03-09 14:36:32 +01:00 committed by Hypolite Petovan
parent 2d263b08e3
commit d03dedee63
2 changed files with 4 additions and 1 deletions

View File

@ -135,6 +135,9 @@ class LoggerFactory
switch ($config->get('system', 'logger_config', 'stream')) { switch ($config->get('system', 'logger_config', 'stream')) {
case 'monolog': case 'monolog':
$loggerTimeZone = new \DateTimeZone('UTC');
Monolog\Logger::setTimezone($loggerTimeZone);
$logger = new Monolog\Logger($channel); $logger = new Monolog\Logger($channel);
$logger->pushProcessor(new Monolog\Processor\PsrLogMessageProcessor()); $logger->pushProcessor(new Monolog\Processor\PsrLogMessageProcessor());
$logger->pushProcessor(new Monolog\Processor\ProcessIdProcessor()); $logger->pushProcessor(new Monolog\Processor\ProcessIdProcessor());

View File

@ -134,7 +134,7 @@ class StreamLogger extends AbstractLogger
$record = array_merge($record, ['uid' => $this->logUid, 'process_id' => $this->pid]); $record = array_merge($record, ['uid' => $this->logUid, 'process_id' => $this->pid]);
$logMessage = ''; $logMessage = '';
$logMessage .= DateTimeFormat::localNow() . ' '; $logMessage .= DateTimeFormat::utcNow() . ' ';
$logMessage .= $this->channel . ' '; $logMessage .= $this->channel . ' ';
$logMessage .= '[' . strtoupper($level) . ']: '; $logMessage .= '[' . strtoupper($level) . ']: ';
$logMessage .= $this->psrInterpolate($message, $context) . ' '; $logMessage .= $this->psrInterpolate($message, $context) . ' ';