refactor: slog替换logrus、日志操作统一、支持json、text格式等

This commit is contained in:
meilin.huang
2023-09-02 17:24:18 +08:00
parent d51cd4b289
commit 899a3a8243
47 changed files with 685 additions and 293 deletions

View File

@@ -1,10 +1,28 @@
package config
import "path"
import (
"mayfly-go/pkg/logx"
"path"
)
type Log struct {
Level string `yaml:"level"`
File *LogFile `yaml:"file"`
Level string `yaml:"level"`
Type string `yaml:"type"`
AddSource bool `yaml:"add-source"`
File LogFile `yaml:"file"`
}
func (l *Log) Default() {
if l.Level == "" {
l.Level = "info"
logx.Warnf("未配置log.level, 默认值: %s", l.Level)
}
if l.Type == "" {
l.Type = "text"
}
if l.File.Name == "" {
l.File.Name = "mayfly-go.log"
}
}
type LogFile struct {