MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / InitializeLogger

Function InitializeLogger

cmd/internal/shared/init.go:48–67  ·  view source on GitHub ↗

InitializeLogger initializes the logger.

(conf *config.Log)

Source from the content-addressed store, hash-verified

46
47// InitializeLogger initializes the logger.
48func InitializeLogger(conf *config.Log) (log.Stack, error) {
49 var (
50 logHandler log.Handler
51 err error
52 )
53 format := strings.ToLower(conf.Format)
54 switch format {
55 case "json", "console":
56 logHandler, err = log.NewZap(format)
57 if err != nil {
58 return nil, ErrInitializeLogger.WithCause(err)
59 }
60 default:
61 return nil, ErrInvalidLogFormat.WithAttributes("format", format)
62 }
63 return log.NewLogger(
64 logHandler,
65 log.WithLevel(conf.Level),
66 ), nil
67}

Callers 2

root.goFile · 0.92
preRunFunction · 0.92

Calls 5

NewZapFunction · 0.92
NewLoggerFunction · 0.92
WithLevelFunction · 0.92
WithCauseMethod · 0.45
WithAttributesMethod · 0.45

Tested by

no test coverage detected