Restructure project
This commit is contained in:
parent
e44e7caa11
commit
16b2f17301
46 changed files with 1744 additions and 1265 deletions
33
internal/logging/logging.go
Normal file
33
internal/logging/logging.go
Normal file
|
@ -0,0 +1,33 @@
|
|||
package logging
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapcore"
|
||||
)
|
||||
|
||||
func CreateLogger(logLevel string) *zap.Logger {
|
||||
encoderCfg := zap.NewProductionEncoderConfig()
|
||||
encoderCfg.TimeKey = "time"
|
||||
encoderCfg.EncodeTime = zapcore.TimeEncoderOfLayout(time.StampMilli)
|
||||
|
||||
level := zap.NewAtomicLevelAt(zap.InfoLevel)
|
||||
zapLevel, err := zap.ParseAtomicLevel(logLevel)
|
||||
if err == nil {
|
||||
level = zapLevel
|
||||
}
|
||||
|
||||
config := zap.Config{
|
||||
Level: level,
|
||||
Development: false,
|
||||
DisableCaller: false,
|
||||
DisableStacktrace: false,
|
||||
Sampling: nil,
|
||||
Encoding: "json",
|
||||
EncoderConfig: encoderCfg,
|
||||
OutputPaths: []string{"stdout"},
|
||||
ErrorOutputPaths: []string{"stderr"},
|
||||
}
|
||||
return zap.Must(config.Build())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue