修改日志

main
lzf 2024-09-30 15:41:29 +08:00
parent 85d7510113
commit fb4fee6e30
1 changed files with 17 additions and 2 deletions

View File

@ -26,6 +26,9 @@ var (
"ERROR": zapcore.ErrorLevel, "ERROR": zapcore.ErrorLevel,
"FATAL": zapcore.FatalLevel, "FATAL": zapcore.FatalLevel,
} }
defaultLogLevel = DebugLevel
// DefaultConfig 默认配置 // DefaultConfig 默认配置
DefaultConfig = &Config{ DefaultConfig = &Config{
Level: DebugLevel, Level: DebugLevel,
@ -63,8 +66,20 @@ type (
} }
) )
// Init 覆盖默认日志 func SetLogLevel(level string) {
func Init(serverName string, config *Config) { defaultLogLevel = level
}
func Init() {
globalLog = NewLogger("debug", &Config{
Level: defaultLogLevel,
NeedLogFile: false,
ConsoleWriter: os.Stdout,
})
}
// InitWithConfig 覆盖默认日志
func InitWithConfig(serverName string, config *Config) {
globalLog = NewLogger(serverName, config) globalLog = NewLogger(serverName, config)
} }