From fb4fee6e3022b9e3a9b72fc018ba0744e2e5cce9 Mon Sep 17 00:00:00 2001 From: lzf Date: Mon, 30 Sep 2024 15:41:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mylog/log.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/mylog/log.go b/mylog/log.go index fa5ac1b..acf7ee2 100644 --- a/mylog/log.go +++ b/mylog/log.go @@ -26,6 +26,9 @@ var ( "ERROR": zapcore.ErrorLevel, "FATAL": zapcore.FatalLevel, } + + defaultLogLevel = DebugLevel + // DefaultConfig 默认配置 DefaultConfig = &Config{ Level: DebugLevel, @@ -63,8 +66,20 @@ type ( } ) -// Init 覆盖默认日志 -func Init(serverName string, config *Config) { +func SetLogLevel(level string) { + 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) }