fix logger bug
This commit is contained in:
16
conf/new.go
16
conf/new.go
@@ -104,3 +104,19 @@ func CheckIP(ip string) string {
|
||||
}
|
||||
return ip
|
||||
}
|
||||
|
||||
// 初始化Logger配置
|
||||
func InitLoggerConf(cfg *LogConf) *LogConf {
|
||||
if cfg == nil {
|
||||
return &LogConf{
|
||||
Name: strings.ToLower(vars.ServiceKey),
|
||||
Level: vars.LogLevel(vars.DEBUG),
|
||||
Dir: cfg.Dir,
|
||||
Endpoint: cfg.Endpoint,
|
||||
Console: cfg.Console,
|
||||
File: cfg.File,
|
||||
Remote: cfg.Remote,
|
||||
}
|
||||
}
|
||||
return cfg
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package conf
|
||||
|
||||
import "git.apinb.com/bsm-sdk/core/vars"
|
||||
|
||||
type Base struct {
|
||||
Service string `yaml:"Service"` // 服务名称
|
||||
Port string `yaml:"Port"` // 服务监听端口,0为自动随机端口
|
||||
@@ -82,23 +84,12 @@ type WebSocketConf struct {
|
||||
HandshakeTimeout string `yaml:"HandshakeTimeout"`
|
||||
}
|
||||
|
||||
// LogLevel 日志级别
|
||||
type LogLevel int
|
||||
|
||||
const (
|
||||
DEBUG LogLevel = iota
|
||||
INFO
|
||||
WARN
|
||||
ERROR
|
||||
FATAL
|
||||
)
|
||||
|
||||
type LogConf struct {
|
||||
Name string `yaml:"Name"`
|
||||
Level LogLevel `yaml:"Level"`
|
||||
Dir string `yaml:"Dir"`
|
||||
Endpoint string `yaml:"Endpoint"`
|
||||
Console bool `yaml:"Console"`
|
||||
File bool `yaml:"File"`
|
||||
Remote bool `yaml:"Remote"`
|
||||
Name string `yaml:"Name"`
|
||||
Level vars.LogLevel `yaml:"Level"`
|
||||
Dir string `yaml:"Dir"`
|
||||
Endpoint string `yaml:"Endpoint"`
|
||||
Console bool `yaml:"Console"`
|
||||
File bool `yaml:"File"`
|
||||
Remote bool `yaml:"Remote"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user