Documentation
¶
Index ¶
- Constants
- type AlertHook
- type Arg
- type FileLogWriterConfig
- type Level
- type Log
- type Logger
- type Option
- func WithCompress(compress bool) Option
- func WithFileName(fileName string) Option
- func WithLocalTime(localTime bool) Option
- func WithMaxAge(maxAge int) Option
- func WithMaxBackups(maxBackups int) Option
- func WithMaxSize(maxSize int) Option
- func WithOutputMode(mode OutputMode) Option
- func WithOutputType(outputType OutputType) Option
- func WithTimeEncoder(timeEncoder zapcore.TimeEncoder) Option
- type OutputMode
- type OutputType
Constants ¶
View Source
const ( DefaultLogFileName = "log/a-log.log" // 默认日志文件名 DefaultLogMaxSize = 1024 // 默认日志文件最大大小 DefaultLogMaxAge = 1 // 默认日志文件最大保存天数 DefaultLogMaxBackups = 5 // 默认日志文件最多保存多少个备份 DefaultLogCompress = false // 默认日志文件是否压缩 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileLogWriterConfig ¶
type Log ¶
type Log struct {
FileLogWriterConfig // 文件日志配置
// contains filtered or unexported fields
}
type Logger ¶
type Option ¶
type Option func(*Log) // 日志配置选项
func WithFileName ¶
WithFileName 设置日志文件名,不包含路径,只有在输出方式为文件或者控制台+文件时有效
func WithOutputMode ¶
func WithOutputMode(mode OutputMode) Option
WithOutputMode 设置日志输出方式,控制台、文件、控制台+文件
func WithOutputType ¶
func WithOutputType(outputType OutputType) Option
WithOutputType 设置日志输出类型,JSON或者Console
func WithTimeEncoder ¶
func WithTimeEncoder(timeEncoder zapcore.TimeEncoder) Option
WithTimeEncoder 设置日志时间格式,支持自定义格式
type OutputMode ¶
type OutputMode uint8 // 输出模式
const ( OutputModeStdout OutputMode = iota + 1 // 输出到控制台 OutputModeFile // 输出到文件 OutputModeStdoutAndFile // 同时输出到控制台和文件 )
type OutputType ¶
type OutputType uint8 // 输出类型
const ( OutputJsonType OutputType = iota + 1 // 输出JSON格式 OutputConsoleType // 输出控制台格式 )
Click to show internal directories.
Click to hide internal directories.