teldrive/internal/logger/logger.go

20 lines
476 B
Go
Raw Normal View History

2023-12-03 03:47:23 +08:00
package logger
2023-08-12 19:21:42 +08:00
import (
"os"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
var Logger *zap.Logger
2023-12-03 03:47:23 +08:00
func InitLogger() {
2023-08-12 19:21:42 +08:00
config := zap.NewProductionEncoderConfig()
config.EncodeTime = zapcore.ISO8601TimeEncoder
consoleEncoder := zapcore.NewConsoleEncoder(config)
2023-12-03 05:23:06 +08:00
defaultLogLevel := zapcore.InfoLevel
2023-08-12 19:21:42 +08:00
core := zapcore.NewCore(consoleEncoder, zapcore.AddSync(os.Stdout), defaultLogLevel)
Logger = zap.New(core, zap.AddCaller(), zap.AddStacktrace(zapcore.ErrorLevel))
}