adguardhome-sync/pkg/log/log.go

29 lines
555 B
Go
Raw Normal View History

2021-03-28 06:40:59 +08:00
package log
import (
"go.uber.org/zap"
)
var rootLogger *zap.Logger
// GetLogger returns a named logger
func GetLogger(name string) *zap.SugaredLogger {
return rootLogger.Named(name).Sugar()
}
func init() {
level := zap.InfoLevel
cfg := zap.Config{
Level: zap.NewAtomicLevelAt(level),
Development: false,
Encoding: "console",
EncoderConfig: zap.NewDevelopmentEncoderConfig(),
2021-03-29 02:28:58 +08:00
OutputPaths: []string{"stdout"},
2021-03-28 06:40:59 +08:00
ErrorOutputPaths: []string{"stderr"},
}
rootLogger, _ = cfg.Build()
rootLogger.Sugar()
}