- 新增日志管理模块:操作日志、登录日志、数据变更日志 - 新增敏感词过滤器 (sanitizer) - 新增日志异步写入管理器 - 新增日志定时清理服务 - 优化帖子相关服务和上传服务
64 lines
2.4 KiB
Go
64 lines
2.4 KiB
Go
package config
|
|
|
|
// ServerConfig 服务器配置
|
|
type ServerConfig struct {
|
|
Host string `mapstructure:"host"`
|
|
Port int `mapstructure:"port"`
|
|
Mode string `mapstructure:"mode"`
|
|
}
|
|
|
|
// LogConfig 日志配置
|
|
type LogConfig struct {
|
|
Level string `mapstructure:"level"`
|
|
Encoding string `mapstructure:"encoding"`
|
|
OutputPaths []string `mapstructure:"output_paths"`
|
|
Retention LogRetentionConfig `mapstructure:"retention"`
|
|
Async AsyncLogConfig `mapstructure:"async"`
|
|
Sensitive SensitiveLogConfig `mapstructure:"sensitive"`
|
|
Rotation LogRotationConfig `mapstructure:"rotation"`
|
|
}
|
|
|
|
// LogRetentionConfig 日志保留配置
|
|
type LogRetentionConfig struct {
|
|
AccessLog int `mapstructure:"access_log"` // HTTP访问日志(天)
|
|
OperationLog int `mapstructure:"operation_log"` // 操作日志(天)
|
|
LoginLog int `mapstructure:"login_log"` // 登录日志(天)
|
|
DataChange int `mapstructure:"data_change"` // 数据变更日志(天)
|
|
}
|
|
|
|
// AsyncLogConfig 异步日志配置
|
|
type AsyncLogConfig struct {
|
|
BufferSize int `mapstructure:"buffer_size"` // 通道缓冲大小
|
|
BatchSize int `mapstructure:"batch_size"` // 批量写入大小
|
|
FlushInterval string `mapstructure:"flush_interval"` // 刷新间隔
|
|
WorkerCount int `mapstructure:"worker_count"` // worker数量
|
|
EnableFallback bool `mapstructure:"enable_fallback"` // 启用降级
|
|
FallbackPath string `mapstructure:"fallback_path"` // 降级文件路径
|
|
}
|
|
|
|
// SensitiveLogConfig 敏感日志配置
|
|
type SensitiveLogConfig struct {
|
|
Enabled bool `mapstructure:"enabled"` // 启用脱敏
|
|
MaskFields []string `mapstructure:"mask_fields"` // 需脱敏字段
|
|
}
|
|
|
|
// LogRotationConfig 日志轮转配置
|
|
type LogRotationConfig struct {
|
|
MaxSize int `mapstructure:"max_size"` // 单个文件最大大小(MB)
|
|
MaxAge int `mapstructure:"max_age"` // 最大保留天数
|
|
MaxBackups int `mapstructure:"max_backups"` // 最大备份数
|
|
Compress bool `mapstructure:"compress"` // 压缩
|
|
}
|
|
|
|
// RateLimitConfig 限流配置
|
|
type RateLimitConfig struct {
|
|
Enabled bool `mapstructure:"enabled"`
|
|
RequestsPerMinute int `mapstructure:"requests_per_minute"`
|
|
}
|
|
|
|
// UploadConfig 上传配置
|
|
type UploadConfig struct {
|
|
MaxFileSize int64 `mapstructure:"max_file_size"`
|
|
AllowedTypes []string `mapstructure:"allowed_types"`
|
|
}
|