MCPcopy
hub / github.com/netdata/netdata / newTerminalHandler

Function newTerminalHandler

src/go/logger/handler.go:35–57  ·  view source on GitHub ↗
(w io.Writer)

Source from the content-addressed store, hash-verified

33}
34
35func newTerminalHandler(w io.Writer) slog.Handler {
36 return tint.NewHandler(w, &tint.Options{
37 NoColor: runtime.GOOS == "windows",
38 AddSource: true,
39 Level: Level.lvl,
40 ReplaceAttr: func(groups []string, a slog.Attr) slog.Attr {
41 switch a.Key {
42 case slog.TimeKey:
43 return slog.Attr{}
44 case slog.SourceKey:
45 if !Level.Enabled(slog.LevelDebug) {
46 return slog.Attr{}
47 }
48 case slog.LevelKey:
49 lvl := a.Value.Any().(slog.Level)
50 if s, ok := customLevelsTerm[lvl]; ok {
51 return slog.String(a.Key, s)
52 }
53 }
54 return a
55 },
56 })
57}
58
59func withCallDepth(depth int, sh slog.Handler) slog.Handler {
60 if v, ok := sh.(*callDepthHandler); ok {

Callers 1

newLoggerFunction · 0.85

Calls 2

EnabledMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…