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)
|
|
|
|
defaultLogLevel := zapcore.DebugLevel
|
|
|
|
core := zapcore.NewCore(consoleEncoder, zapcore.AddSync(os.Stdout), defaultLogLevel)
|
|
|
|
Logger = zap.New(core, zap.AddCaller(), zap.AddStacktrace(zapcore.ErrorLevel))
|
|
|
|
}
|