Skip to content

Commit

Permalink
slogutil: imp code
Browse files Browse the repository at this point in the history
  • Loading branch information
Mizzick committed Oct 22, 2024
1 parent 9d54b20 commit c6caad7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions logutil/slogutil/jsonhybrid.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ func NewJSONHybridHandler(w io.Writer, opts *slog.HandlerOptions) (h *JSONHybrid
}
}

// normalAttrValue is a NORMAL value under the [slog.LevelKey] key.
var normalAttrValue = slog.StringValue("NORMAL")
// valueLevelNormal is a NORMAL value under the [slog.LevelKey] key.
var valueLevelNormal = slog.StringValue("NORMAL")

// renameAttrs is a [slog.HandlerOptions.ReplaceAttr] function that renames the
// [slog.LevelKey] key to [keySeverity], and the [slog.MessageKey] key to
Expand All @@ -77,7 +77,7 @@ func renameAttrs(groups []string, a slog.Attr) (res slog.Attr) {
case KeyLevel:
lvl := a.Value.Any().(slog.Level)
if lvl < LevelError {
a.Value = normalAttrValue
a.Value = valueLevelNormal
}

a.Key = keySeverity
Expand Down
6 changes: 3 additions & 3 deletions logutil/slogutil/slogutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ func newReplaceAttr(removeTime bool) func(groups []string, a slog.Attr) (res slo
}
}

// traceAttrValue is a [LevelTrace] value under the [slog.LevelKey] key.
var traceAttrValue = slog.StringValue("TRACE")
// valueLevelTrace is a [LevelTrace] value under the [slog.LevelKey] key.
var valueLevelTrace = slog.StringValue("TRACE")

// ReplaceLevel is a function for [slog.HandlerOptions.ReplaceAttr] that adds
// [LevelTrace] custom name for level attribute.
Expand All @@ -138,7 +138,7 @@ func ReplaceLevel(groups []string, a slog.Attr) (res slog.Attr) {
if a.Key == slog.LevelKey {
lvl := a.Value.Any().(slog.Level)
if lvl == LevelTrace {
a.Value = traceAttrValue
a.Value = valueLevelTrace
}
}

Expand Down

0 comments on commit c6caad7

Please sign in to comment.