fix logger bug

This commit is contained in:
2025-10-04 17:42:26 +08:00
parent 464617626b
commit 5584757ff4
4 changed files with 50 additions and 30 deletions

View File

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

View File

@@ -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"`
}