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) }