Skip to content

Commit e6b3a5d

Browse files
committed
fix: Format text handler time attribute
1 parent c74094b commit e6b3a5d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

logging/logging.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ func Configure() {
5454
logTypeAsString := os.Getenv(GatusConfigLogTypeEnvVar)
5555
switch logTypeAsString {
5656
case "", "TEXT":
57+
logHandlerOptions.ReplaceAttr = func(groups []string, a slog.Attr) slog.Attr {
58+
if a.Key == "time" {
59+
a.Value = slog.StringValue(a.Value.Time().Format("2006-01-02|15:04:05"))
60+
}
61+
return a
62+
}
5763
slog.SetDefault(slog.New(slog.NewTextHandler(os.Stdout, logHandlerOptions)))
5864
slog.Info("Log type set", "type", logTypeAsString)
5965
case "JSON":

0 commit comments

Comments
 (0)