Documentation
¶
Index ¶
- Constants
- Variables
- type BaseHandlerConfig
- type Config
- type FileHandlerConfig
- type FormatterConfig
- type FormatterType
- type HandlerConfig
- type HandlerType
- type JSONFormatterConfig
- type OptionFunc
- func EnableExitOnFatal() OptionFunc
- func SetCacheSize2Logger(size int) OptionFunc
- func SetCacheSize2Report(size int) OptionFunc
- func SetEnableReport() OptionFunc
- func SetFileBackupCount2Logger(count int) OptionFunc
- func SetFileBackupCount2Report(count int) OptionFunc
- func SetFileDir2Logger(path string) OptionFunc
- func SetFileDir2Report(path string) OptionFunc
- func SetFileHandlerConfig2Logger(fileCfg FileHandlerConfig) OptionFunc
- func SetFileHandlerConfig2Report(fileCfg FileHandlerConfig) OptionFunc
- func SetFileMaxSize2Logger(size int64) OptionFunc
- func SetFileMaxSize2Report(size int64) OptionFunc
- func SetFileName2Logger(name string) OptionFunc
- func SetFileName2Report(name string) OptionFunc
- func SetFileRematch2Logger(pattern string) OptionFunc
- func SetFileRematch2Report(pattern string) OptionFunc
- func SetFileRotatorType2Logger(typ RotatorType) OptionFunc
- func SetFileRotatorType2Report(typ RotatorType) OptionFunc
- func SetFileTimeFmtSuffix2Logger(timeFmt string) OptionFunc
- func SetFileTimeFmtSuffix2Report(timeFmt string) OptionFunc
- func SetFileWhen2Logger(when RotatorWhenType) OptionFunc
- func SetFileWhen2Report(when RotatorWhenType) OptionFunc
- func SetFormatterConfig2Logger(formatterCfg FormatterConfig) OptionFunc
- func SetFormatterConfig2Report(formatterCfg FormatterConfig) OptionFunc
- func SetFormatterType2Logger(typ FormatterType) OptionFunc
- func SetFormatterType2Report(typ FormatterType) OptionFunc
- func SetHandlerType2Logger(typ HandlerType) OptionFunc
- func SetHandlerType2Report(typ HandlerType) OptionFunc
- func SetLevel2Logger(lvl level.LogLevel) OptionFunc
- func SetLevel2Report(lvl level.LogLevel) OptionFunc
- func SetLoggerName(name string) OptionFunc
- func SetStreamer2Logger(streamer filter.IStreamer) OptionFunc
- func SetStreamer2Report(streamer filter.IStreamer) OptionFunc
- func SetSyslogHandlerConfig2Logger(syslogCfg SyslogHandlerConfig) OptionFunc
- func SetSyslogHandlerConfig2Report(syslogCfg SyslogHandlerConfig) OptionFunc
- type RotatorType
- type RotatorWhenType
- type StreamHandlerConfig
- type SyslogHandlerConfig
- type TextFormatterConfig
- type XMLFormatterConfig
Constants ¶
View Source
const ( FileRotatorSuffixFmt1 = "20060102150405" FileRotatorSuffixFmt2 = "2006-01-02T15-04-05" FileRotatorSuffixFmt3 = "2006-01-02_15-04-05" )
View Source
const ( FileRotatorReMatch1 = "^\\d{14}(\\.\\w+)?$" FileRotatorReMatch2 = "^\\d{4}-\\d{2}-\\d{2}T\\d{2}-\\d{2}-\\d{2}(\\.\\w+)?$" FileRotatorReMatch3 = "^\\d{4}-\\d{2}-\\d{2}_\\d{2}-\\d{2}-\\d{2}(\\.\\w+)?$" )
View Source
const ( PatternTemplate1 = "%[LoggerName]s (%[Pid]d,%[RoutineId]d) %[DateTime]s.%[Msecs]d %[LevelName]s %[Caller]s %[Message]v" PatternTemplate2 = "<%[TradeId]s> %[LoggerName]s (%[Pid]d,%[RoutineId]d) %[DateTime]s %[LevelName]s %[Caller]s %[Message]v" )
View Source
const (
DefaultTimestampFormat = time.RFC3339
)
Variables ¶
View Source
var GlobalConfig = NewDefaultConfig()
Functions ¶
This section is empty.
Types ¶
type BaseHandlerConfig ¶
type BaseHandlerConfig struct {
HandlerType HandlerType
File FileHandlerConfig
Stream StreamHandlerConfig
Syslog SyslogHandlerConfig
Formatter FormatterConfig
Filter filter.IFilter
}
type Config ¶
type Config struct {
ExitOnFatal bool
IsRecordCaller bool
EnableReport bool
LoggerLevel level.LogLevel
ReportLevel level.LogLevel
ReportCacheSize int
LoggerCacheSize int
LoggerName string
Handler HandlerConfig `json:"handler"`
ExitFunc func(code int) // Function to exit the application, defaults to `os.Exit()`
TradeIDFunc func(entry *message.Entry) string
OnError func(msg *message.Entry, err error)
}
func NewDefaultConfig ¶
func NewDefaultConfig() *Config
type FileHandlerConfig ¶
type FileHandlerConfig struct {
RotatorType RotatorType
FileDir string
FileName string
MaxFileSize int64
BackupCount int
When RotatorWhenType // used in TimeRotator and TimeAndSizeRotator
IntervalStep int64
TimeSuffixFmt string
ReMatch string
FileSuffix string
MultiProcessWrite bool
ErrCallback func(err error)
}
type FormatterConfig ¶
type FormatterConfig struct {
TimestampFormat string
FormatterType FormatterType
Text TextFormatterConfig
Json JSONFormatterConfig
Xml XMLFormatterConfig
}
type FormatterType ¶
type FormatterType int
const ( FormatterTypeText FormatterType = 1 FormatterTypeJson FormatterType = 2 FormatterTypeXml FormatterType = 3 )
type HandlerConfig ¶
type HandlerConfig struct {
LogHandlerConfig BaseHandlerConfig
ReportHandlerConfig BaseHandlerConfig
}
type HandlerType ¶
type HandlerType int
const ( HandlerTypeDefault HandlerType = 0 HandlerTypeFile HandlerType = 1 HandlerTypeStream HandlerType = 2 HandlerTypeSyslog HandlerType = 3 )
type JSONFormatterConfig ¶
type OptionFunc ¶
type OptionFunc func(config *Config)
func EnableExitOnFatal ¶ added in v0.2.3
func EnableExitOnFatal() OptionFunc
func SetCacheSize2Logger ¶
func SetCacheSize2Logger(size int) OptionFunc
func SetCacheSize2Report ¶
func SetCacheSize2Report(size int) OptionFunc
func SetEnableReport ¶
func SetEnableReport() OptionFunc
func SetFileBackupCount2Logger ¶
func SetFileBackupCount2Logger(count int) OptionFunc
func SetFileBackupCount2Report ¶
func SetFileBackupCount2Report(count int) OptionFunc
func SetFileDir2Logger ¶
func SetFileDir2Logger(path string) OptionFunc
func SetFileDir2Report ¶
func SetFileDir2Report(path string) OptionFunc
func SetFileHandlerConfig2Logger ¶ added in v0.2.0
func SetFileHandlerConfig2Logger(fileCfg FileHandlerConfig) OptionFunc
func SetFileHandlerConfig2Report ¶ added in v0.2.0
func SetFileHandlerConfig2Report(fileCfg FileHandlerConfig) OptionFunc
func SetFileMaxSize2Logger ¶
func SetFileMaxSize2Logger(size int64) OptionFunc
func SetFileMaxSize2Report ¶
func SetFileMaxSize2Report(size int64) OptionFunc
func SetFileName2Logger ¶
func SetFileName2Logger(name string) OptionFunc
SetFileName2Logger By default, the file name is the same as the logger name, if you need to specify special can be set through this config.
func SetFileName2Report ¶
func SetFileName2Report(name string) OptionFunc
SetFileName2Report By default, the file name is the same as the logger name, if you need to specify special can be set through this config.
func SetFileRematch2Logger ¶
func SetFileRematch2Logger(pattern string) OptionFunc
func SetFileRematch2Report ¶
func SetFileRematch2Report(pattern string) OptionFunc
func SetFileRotatorType2Logger ¶
func SetFileRotatorType2Logger(typ RotatorType) OptionFunc
func SetFileRotatorType2Report ¶
func SetFileRotatorType2Report(typ RotatorType) OptionFunc
func SetFileTimeFmtSuffix2Logger ¶
func SetFileTimeFmtSuffix2Logger(timeFmt string) OptionFunc
func SetFileTimeFmtSuffix2Report ¶
func SetFileTimeFmtSuffix2Report(timeFmt string) OptionFunc
func SetFileWhen2Logger ¶
func SetFileWhen2Logger(when RotatorWhenType) OptionFunc
func SetFileWhen2Report ¶
func SetFileWhen2Report(when RotatorWhenType) OptionFunc
func SetFormatterConfig2Logger ¶ added in v0.2.0
func SetFormatterConfig2Logger(formatterCfg FormatterConfig) OptionFunc
func SetFormatterConfig2Report ¶ added in v0.2.0
func SetFormatterConfig2Report(formatterCfg FormatterConfig) OptionFunc
func SetFormatterType2Logger ¶ added in v0.2.0
func SetFormatterType2Logger(typ FormatterType) OptionFunc
func SetFormatterType2Report ¶ added in v0.2.0
func SetFormatterType2Report(typ FormatterType) OptionFunc
func SetHandlerType2Logger ¶
func SetHandlerType2Logger(typ HandlerType) OptionFunc
func SetHandlerType2Report ¶
func SetHandlerType2Report(typ HandlerType) OptionFunc
func SetLevel2Logger ¶
func SetLevel2Logger(lvl level.LogLevel) OptionFunc
func SetLevel2Report ¶
func SetLevel2Report(lvl level.LogLevel) OptionFunc
func SetLoggerName ¶
func SetLoggerName(name string) OptionFunc
SetLoggerName Set the name of the logger, the default is the name of the program.
func SetStreamer2Logger ¶ added in v0.2.0
func SetStreamer2Logger(streamer filter.IStreamer) OptionFunc
func SetStreamer2Report ¶ added in v0.2.0
func SetStreamer2Report(streamer filter.IStreamer) OptionFunc
func SetSyslogHandlerConfig2Logger ¶ added in v0.2.0
func SetSyslogHandlerConfig2Logger(syslogCfg SyslogHandlerConfig) OptionFunc
func SetSyslogHandlerConfig2Report ¶ added in v0.2.0
func SetSyslogHandlerConfig2Report(syslogCfg SyslogHandlerConfig) OptionFunc
type RotatorType ¶
type RotatorType int
const ( FileRotatorTypeTime RotatorType = 1 FileRotatorTypeSize RotatorType = 2 FileRotatorTypeTimeAndSize RotatorType = 3 )
type RotatorWhenType ¶
type RotatorWhenType int
const ( FileRotatorWhenSecond RotatorWhenType = 1 FileRotatorWhenMinute RotatorWhenType = 2 FileRotatorWhenHour RotatorWhenType = 3 FileRotatorWhenDay RotatorWhenType = 4 )
type StreamHandlerConfig ¶
type SyslogHandlerConfig ¶
type TextFormatterConfig ¶
type TextFormatterConfig struct {
PatternStyle string // style template for formatting the data, which determines the order of the fields and the presentation style.
EnableQuote bool // keep the string literal, while escaping safely if necessary.
EnableQuoteEmptyFields bool // when the value of field is empty, keep the string literal.
DisableColors bool // adding color rendering to the output.
}
type XMLFormatterConfig ¶
type XMLFormatterConfig struct {
}
Click to show internal directories.
Click to hide internal directories.