-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.go
37 lines (34 loc) · 988 Bytes
/
logger.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// SPDX-FileCopyrightText: 2024 Comcast Cable Communications Management, LLC
// SPDX-License-Identifier: Apache-2.0
package skeleton
import (
"github.com/xmidt-org/sallust"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
// Create the logger and configure it based on if the program is in
// debug mode or normal mode.
func provideLogger(cli *CLI, cfg sallust.Config) (*zap.Logger, error) {
if cli.Dev {
cfg.Level = "DEBUG"
cfg.Development = true
cfg.Encoding = "console"
cfg.EncoderConfig = sallust.EncoderConfig{
TimeKey: "T",
LevelKey: "L",
NameKey: "N",
CallerKey: "C",
FunctionKey: zapcore.OmitKey,
MessageKey: "M",
StacktraceKey: "S",
LineEnding: zapcore.DefaultLineEnding,
EncodeLevel: "capitalColor",
EncodeTime: "RFC3339",
EncodeDuration: "string",
EncodeCaller: "short",
}
cfg.OutputPaths = []string{"stderr"}
cfg.ErrorOutputPaths = []string{"stderr"}
}
return cfg.Build()
}