MCPcopy Create free account
hub / github.com/cortexproject/cortex / InitLogger

Function InitLogger

pkg/util/log/log.go:41–53  ·  view source on GitHub ↗

InitLogger initialises the global gokit logger (util_log.Logger) and overrides the default logger for the server.

(cfg *server.Config)

Source from the content-addressed store, hash-verified

39// InitLogger initialises the global gokit logger (util_log.Logger) and overrides the
40// default logger for the server.
41func InitLogger(cfg *server.Config) {
42 l := newLoggerWithFormat(cfg.LogFormat)
43
44 // when use util_log.Logger, skip 6 stack frames.
45 Logger = newPrometheusLoggerFrom(l, cfg.LogLevel, "caller", log.Caller(6))
46 SLogger = GoKitLogToSlog(Logger)
47
48 // cfg.Log wraps log function, skip 7 stack frames to get caller information.
49 // this works in go 1.12, but doesn't work in versions earlier.
50 // it will always shows the wrapper function generated by compiler
51 // marked <autogenerated> in old versions.
52 cfg.Log = logging.GoKit(newPrometheusLoggerFrom(l, cfg.LogLevel, "caller", log.Caller(7)))
53}
54
55// PrometheusLogger exposes Prometheus counters for each of go-kit's log levels.
56type PrometheusLogger struct {

Callers 4

mainFunction · 0.92
TestInitLoggerFunction · 0.85

Calls 3

newLoggerWithFormatFunction · 0.85
newPrometheusLoggerFromFunction · 0.85
GoKitLogToSlogFunction · 0.85

Tested by 3

TestInitLoggerFunction · 0.68