Skip to content

Commit f774d1d

Browse files
authored
Merge pull request #1 from fauzanpurwaw/main
Update Timestamp Timezone Based on Config or app_timezone
2 parents 15d1084 + a251376 commit f774d1d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/DiscordHandler.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class DiscordHandler extends AbstractProcessingHandler
1919
private $context;
2020
private $maxFieldLength;
2121
private $maxDescriptionLength;
22+
private $timezone;
2223

2324
/**
2425
* Discord Handler constructor.
@@ -33,6 +34,7 @@ public function __construct($config)
3334
$this->context = $config['context'] ?? false;
3435
$this->maxFieldLength = $config['max_field_length'] ?? 1024;
3536
$this->maxDescriptionLength = $config['max_description_length'] ?? 4000;
37+
$this->timezone = $config['timezone'] ?? config('app.timezone', 'Asia/Jakarta');
3638

3739
parent::__construct($config['level'] ?? 'debug', $this->bubble);
3840
}
@@ -354,7 +356,7 @@ private function buildEmbeds(LogRecord $record, array $logInfo, array $fields):
354356
'title' => $this->buildTitle($logInfo),
355357
'description' => $this->buildDescription($record),
356358
'color' => $logInfo['color'],
357-
'timestamp' => $record->datetime->format('Y-m-d\TH:i:s.v\Z'),
359+
'timestamp' => $record->datetime->setTimezone(new DateTimeZone($this->timezone))->format('Y-m-d\TH:i:s.vP')
358360
'fields' => $fields,
359361
'footer' => [
360362
'text' => $this->suffix . ' • Laravel Discord Logger',
@@ -426,7 +428,7 @@ private function buildContextEmbed(LogRecord $record): ?array
426428
'title' => '📋 Full Context & Extra Data',
427429
'description' => "```json\n" . Str::limit($contextJson, $this->maxDescriptionLength - 15) . "\n```",
428430
'color' => 0x95A5A6, // Gray
429-
'timestamp' => $record->datetime->format('Y-m-d\TH:i:s.v\Z')
431+
'timestamp' => $record->datetime->setTimezone(new DateTimeZone($this->timezone))->format('Y-m-d\TH:i:s.vP')
430432
];
431433
}
432434

0 commit comments

Comments
 (0)