Documentation
¶
Index ¶
- type Logging
- func (l *Logging) AddSkipPath(path string) *Logging
- func (l *Logging) Clone() internal.Configurable
- func (l *Logging) Disable() *Logging
- func (l *Logging) Enable() *Logging
- func (l *Logging) EnableLogging() *Logging
- func (l *Logging) EnableRequestResponse() *Logging
- func (l *Logging) Get() any
- func (l *Logging) GetFormatterType() logger.FormatType
- func (l *Logging) GetLogLevel() string
- func (l *Logging) GetOutputType() logger.OutputType
- func (l *Logging) IsEnabled() bool
- func (l *Logging) Set(data any)
- func (l *Logging) ToLoggerInstance() *logger.Logger
- func (l *Logging) Validate() error
- func (l *Logging) WithBufferSize(bufferSize int) *Logging
- func (l *Logging) WithCompress(compress bool) *Logging
- func (l *Logging) WithEnableRequest(enableRequest bool) *Logging
- func (l *Logging) WithEnableResponse(enableResponse bool) *Logging
- func (l *Logging) WithEnabled(enabled bool) *Logging
- func (l *Logging) WithFilePath(filePath string) *Logging
- func (l *Logging) WithFilePermission(permission uint32) *Logging
- func (l *Logging) WithFormat(format logger.FormatType) *Logging
- func (l *Logging) WithLevel(level string) *Logging
- func (l *Logging) WithMaxAge(maxAge int) *Logging
- func (l *Logging) WithMaxBackups(maxBackups int) *Logging
- func (l *Logging) WithMaxSize(maxSize int) *Logging
- func (l *Logging) WithModuleName(moduleName string) *Logging
- func (l *Logging) WithOutput(output logger.OutputType) *Logging
- func (l *Logging) WithSkipPaths(skipPaths []string) *Logging
- func (l *Logging) WithTimeFormat(timeFormat string) *Logging
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Logging ¶
type Logging struct {
ModuleName string `mapstructure:"module-name" yaml:"module-name" json:"moduleName"` // 模块名称
Enabled bool `mapstructure:"enabled" yaml:"enabled" json:"enabled"` // 是否启用日志
Level string `mapstructure:"level" yaml:"level" json:"level"` // 日志级别 (debug, info, warn, error)
Format logger.FormatType `mapstructure:"format" yaml:"format" json:"format"` // 日志格式 (json, text, xml, csv)
Prefix string `mapstructure:"prefix" yaml:"prefix" json:"prefix"` // 日志前缀(如:[WSC])
ShowCaller bool `mapstructure:"show-caller" yaml:"show-caller" json:"showCaller"` // 是否显示调用者信息
Colorful bool `mapstructure:"colorful" yaml:"colorful" json:"colorful"` // 是否使用彩色输出
TimeFormat string `mapstructure:"time-format" yaml:"time-format" json:"timeFormat"` // 时间格式(如:2006-01-02 15:04:05.000)
Output logger.OutputType `mapstructure:"output" yaml:"output" json:"output"` // 输出目标 (console, file, rotate, stdout, stderr)
FilePath string `mapstructure:"file-path" yaml:"file-path" json:"filePath"` // 日志文件路径
MaxSize int `mapstructure:"max-size" yaml:"max-size" json:"maxSize"` // 最大文件大小(MB)
MaxBackups int `mapstructure:"max-backups" yaml:"max-backups" json:"maxBackups"` // 最大备份文件数
MaxAge int `mapstructure:"max-age" yaml:"max-age" json:"maxAge"` // 最大保存天数
Compress bool `mapstructure:"compress" yaml:"compress" json:"compress"` // 是否压缩
FilePermission uint32 `mapstructure:"file-permission" yaml:"file-permission" json:"filePermission"` // 文件权限(十进制值,如:420 表示 0644)
BufferSize int `mapstructure:"buffer-size" yaml:"buffer-size" json:"bufferSize"` // 缓冲区大小(字节)
SkipPaths []string `mapstructure:"skip-paths" yaml:"skip-paths" json:"skipPaths"` // 跳过的路径
EnableRequest bool `mapstructure:"enable-request" yaml:"enable-request" json:"enableRequest"` // 是否记录请求
EnableResponse bool `mapstructure:"enable-response" yaml:"enable-response" json:"enableResponse"` // 是否记录响应
MaxBodySize int `mapstructure:"max-body-size" yaml:"max-body-size" json:"maxBodySize"` // 最大日志体大小(字节)
SensitiveMask string `mapstructure:"sensitive-mask" yaml:"sensitive-mask" json:"sensitiveMask"` // 敏感数据掩码
SensitiveKeys []string `mapstructure:"sensitive-keys" yaml:"sensitive-keys" json:"sensitiveKeys"` // 敏感字段关键词
SlowHTTPThreshold int64 `mapstructure:"slow-http-threshold" yaml:"slow-http-threshold" json:"slowHttpThreshold"` // HTTP慢请求阈值(毫秒)
SlowGRPCThreshold int64 `mapstructure:"slow-grpc-threshold" yaml:"slow-grpc-threshold" json:"slowGrpcThreshold"` // GRPC慢请求阈值(毫秒)
SlowStreamThreshold int64 `mapstructure:"slow-stream-threshold" yaml:"slow-stream-threshold" json:"slowStreamThreshold"` // 流式请求慢请求阈值(毫秒)
LoggableContentTypes []string `mapstructure:"loggable-content-types" yaml:"loggable-content-types" json:"loggableContentTypes"` // 可记录的 Content-Type
}
Logging 日志中间件配置
func (*Logging) AddSkipPath ¶
AddSkipPath 添加跳过的路径
func (*Logging) EnableRequestResponse ¶
EnableRequestResponse 同时启用请求和响应记录
func (*Logging) GetFormatterType ¶
func (l *Logging) GetFormatterType() logger.FormatType
GetFormatterType 获取 go-logger 的格式化类型
func (*Logging) GetOutputType ¶
func (l *Logging) GetOutputType() logger.OutputType
GetOutputType 获取 go-logger 的输出类型
func (*Logging) ToLoggerInstance ¶
ToLoggerInstance 将 Logging 配置转换为 go-logger 的 Logger 实例
func (*Logging) WithBufferSize ¶
WithBufferSize 设置缓冲区大小
func (*Logging) WithCompress ¶
WithCompress 设置是否压缩
func (*Logging) WithEnableRequest ¶
WithEnableRequest 设置是否记录请求
func (*Logging) WithEnableResponse ¶
WithEnableResponse 设置是否记录响应
func (*Logging) WithEnabled ¶
WithEnabled 设置是否启用日志
func (*Logging) WithFilePath ¶
WithFilePath 设置日志文件路径
func (*Logging) WithFilePermission ¶
WithFilePermission 设置文件权限
func (*Logging) WithFormat ¶
func (l *Logging) WithFormat(format logger.FormatType) *Logging
WithFormat 设置日志格式
func (*Logging) WithMaxBackups ¶
WithMaxBackups 设置最大备份文件数
func (*Logging) WithMaxSize ¶
WithMaxSize 设置最大文件大小
func (*Logging) WithModuleName ¶
WithModuleName 设置模块名称
func (*Logging) WithOutput ¶
func (l *Logging) WithOutput(output logger.OutputType) *Logging
WithOutput 设置输出目标
func (*Logging) WithSkipPaths ¶
WithSkipPaths 设置跳过的路径
func (*Logging) WithTimeFormat ¶
WithTimeFormat 设置时间格式
Click to show internal directories.
Click to hide internal directories.