Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: timezone for logs #241

Merged
merged 2 commits into from
Jun 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion plugin/shared/Helpers/PluginLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Transbank\Plugin\Helpers;

use DateTimeZone;
use Monolog\Logger;
use Monolog\Handler\RotatingFileHandler;
use Monolog\Formatter\LineFormatter;
Expand Down Expand Up @@ -32,7 +33,8 @@ public function __construct(LogConfig $config)

private function initializeLogger(string $logFilePath)
{
$dateFormat = "Y-m-d H:i:s";
$ecommerceTz = new DateTimeZone(wc_timezone_string());
$dateFormat = "Y-m-d H:i:s P";
$output = "%datetime% > %level_name% > %message% %context% %extra%\n";
$formatter = new LineFormatter($output, $dateFormat);

Expand All @@ -44,6 +46,7 @@ private function initializeLogger(string $logFilePath)
$stream->setFormatter($formatter);

$this->logger = new Logger('transbank');
$this->logger->setTimezone($ecommerceTz);
$this->logger->pushHandler($stream);
}

Expand Down
Loading