Skip to content

Commit

Permalink
Revert "fix(promslog): always use UTC for time (#735)"
Browse files Browse the repository at this point in the history
This reverts commit 145b50a.

See discussion on Slack. We should first decide which log format we
want before changing it from what is already released in
prometheus/prometheus.

Signed-off-by: beorn7 <[email protected]>
  • Loading branch information
beorn7 committed Dec 5, 2024
1 parent d88ee1f commit f4397d1
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions promslog/slog.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,13 @@ var (

return a
}
defaultReplaceAttrFunc = func(groups []string, a slog.Attr) slog.Attr {
key := a.Key
switch key {
case slog.TimeKey:
t := a.Value.Time()
a.Value = slog.TimeValue(t.UTC())
case slog.SourceKey:
src, _ := a.Value.Any().(*slog.Source)
truncateSourceAttrFunc = func(groups []string, a slog.Attr) slog.Attr {
if a.Key != slog.SourceKey {
return a
}

if src, ok := a.Value.Any().(*slog.Source); ok {
a.Value = slog.StringValue(filepath.Base(src.File) + ":" + strconv.Itoa(src.Line))
default:
}

return a
Expand Down Expand Up @@ -181,7 +178,7 @@ func New(config *Config) *slog.Logger {
logHandlerOpts := &slog.HandlerOptions{
Level: config.Level.lvl,
AddSource: true,
ReplaceAttr: defaultReplaceAttrFunc,
ReplaceAttr: truncateSourceAttrFunc,
}

if config.Style == GoKitStyle {
Expand Down

0 comments on commit f4397d1

Please sign in to comment.