mirror of
				https://gitee.com/dromara/mayfly-go
				synced 2025-11-04 00:10:25 +08:00 
			
		
		
		
	refactor: slog替换logrus、日志操作统一、支持json、text格式等
This commit is contained in:
		@@ -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 {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user