Documentation ¶
Index ¶
- Constants
- Variables
- func Close()
- func Debug(fmt string, args ...interface{})
- func Error(fmt string, args ...interface{})
- func Fatal(fmt string, args ...interface{})
- func Info(fmt string, args ...interface{})
- func Register(w Writer)
- func SetLayout(layout string)
- func SetLevel(lvl int)
- func SetupLog(lc LogConfig) (err error)
- func SetupLogWithConf(file string) (err error)
- func ShowFullPath(show bool)
- func Warn(fmt string, args ...interface{})
- type ConfAliLogHubWriter
- type ConfConsoleWriter
- type ConfFileWriter
- type ConfKafKaWriter
- type ConsoleWriter
- type FileWriter
- type Flusher
- type KafKaMSGFields
- type KafKaWriter
- type LogConfig
- type Logger
- func (l *Logger) Close()
- func (l *Logger) Debug(fmt string, args ...interface{})
- func (l *Logger) Error(fmt string, args ...interface{})
- func (l *Logger) Fatal(fmt string, args ...interface{})
- func (l *Logger) Info(fmt string, args ...interface{})
- func (l *Logger) Register(w Writer)
- func (l *Logger) SetLayout(layout string)
- func (l *Logger) SetLevel(lvl int)
- func (l *Logger) Warn(fmt string, args ...interface{})
- type Record
- type Rotater
- type ShortRecord
- type SyslogWriter
- type Writer
Constants ¶
const ( DEBUG = iota INFO WARNING ERROR FATAL )
Variables ¶
var GlobalLevel = DEBUG
GlobalLevel global level
var (
LevelFlags = [...]string{"DEBUG", "INFO", "WARN", "ERROR", "FATAL"}
)
Functions ¶
func Debug ¶
func Debug(fmt string, args ...interface{})
Debug loggerDefault deliver record to writer
func Error ¶
func Error(fmt string, args ...interface{})
Error loggerDefault deliver record to writer
func Fatal ¶
func Fatal(fmt string, args ...interface{})
Fatal loggerDefault deliver record to writer
func SetLevel ¶
func SetLevel(lvl int)
SetLevel global set level is ignore logger level should be set in specific logger
func SetupLogWithConf ¶
SetupLogWithConf setup log with config file
Types ¶
type ConfAliLogHubWriter ¶
type ConfAliLogHubWriter struct { Level string `json:"level" mapstructure:"level"` Enable bool `json:"enable" mapstructure:"enable"` LogName string `json:"log_name" mapstructure:"log_name"` LogSource string `json:"log_source" mapstructure:"log_source"` ProjectName string `json:"project_name" mapstructure:"project_name"` Endpoint string `json:"endpoint" mapstructure:"endpoint"` AccessKeyId string `json:"access_key_id" mapstructure:"access_key_id"` AccessKeySecret string `json:"access_key_secret" mapstructure:"access_key_secret"` StoreName string `json:"store_name" mapstructure:"store_name"` BufSize int `json:"buf_size" mapstructure:"buf_size"` }
ConfAliLogHubWriter ali log hub writer config
type ConfConsoleWriter ¶
type ConfConsoleWriter struct { Level string `json:"level" mapstructure:"level"` Enable bool `json:"enable" mapstructure:"enable"` Color bool `json:"color" mapstructure:"color"` }
ConfConsoleWriter console writer config
type ConfFileWriter ¶
type ConfFileWriter struct { Level string `json:"level" mapstructure:"level"` LogPath string `json:"log_path" mapstructure:"log_path"` Enable bool `json:"enable" mapstructure:"enable"` }
ConfFileWriter file writer config
type ConfKafKaWriter ¶
type ConfKafKaWriter struct { Level string `json:"level" mapstructure:"level"` Enable bool `json:"enable" mapstructure:"enable"` BufferSize int `json:"buffer_size" mapstructure:"buffer_size"` Debug bool `json:"debug" mapstructure:"debug"` // if true, will output the send msg SpecifyVersion bool `json:"specify_version" mapstructure:"specify_version"` // if use the input version, default false Version string `json:"version" mapstructure:"version"` // used to specify the kafka version, ex: 0.10.0.1 or 1.1.1 Key string `json:"key" mapstructure:"key"` // kafka producer key, temp set, choice field ProducerTopic string `json:"producer_topic" mapstructure:"producer_topic"` ProducerReturnSuccesses bool `json:"producer_return_successes" mapstructure:"producer_return_successes"` ProducerTimeout time.Duration `json:"producer_timeout" mapstructure:"producer_timeout"` // ms Brokers []string `json:"brokers" mapstructure:"brokers"` MSG KafKaMSGFields }
ConfKafKaWriter kafka writer conf
type ConsoleWriter ¶
type ConsoleWriter struct {
// contains filtered or unexported fields
}
ConsoleWriter console writer define
func NewConsoleWriter ¶
func NewConsoleWriter() *ConsoleWriter
NewConsoleWriter create new console writer
func NewConsoleWriterWithLevel ¶
func NewConsoleWriterWithLevel(level int) *ConsoleWriter
NewConsoleWriterWithLevel create new console writer with level
func (*ConsoleWriter) Init ¶
func (w *ConsoleWriter) Init() error
Init console init without implement
func (*ConsoleWriter) SetColor ¶
func (w *ConsoleWriter) SetColor(c bool)
SetColor console output color control
func (*ConsoleWriter) Write ¶
func (w *ConsoleWriter) Write(r *Record) (err error)
Write console write
type FileWriter ¶
type FileWriter struct {
// contains filtered or unexported fields
}
FileWriter file writer define
func NewFileWriterWithLevel ¶
func NewFileWriterWithLevel(level int) *FileWriter
NewFileWriterWithLevel create new file writer with level
func (*FileWriter) SetPathPattern ¶
func (w *FileWriter) SetPathPattern(pattern string) error
SetPathPattern for file writer
type KafKaMSGFields ¶
type KafKaMSGFields struct { ESIndex string `json:"es_index" mapstructure:"es_index"` // required, init field Level string `json:"level"` // dynamic, set by logger Code string `json:"file"` // dynamic, source code file:line_number Message string `json:"message"` // dynamic, message ServerIP string `json:"server_ip" mapstructure:"server_ip"` // required, init field, set by app PublicIP string `json:"public_ip" mapstructure:"public_ip"` // required, init field, set by app Timestamp string `json:"timestamp" mapstructure:"timestamp"` // required, dynamic, set by logger Now int64 `json:"now" mapstructure:"now"` // choice, unix timestamp, second ExtraFields map[string]interface{} `json:"extra_fields" mapstructure:"extra_fields"` // extra fields will be added }
KafKaMSGFields kafka msg fields
type KafKaWriter ¶
type KafKaWriter struct {
// contains filtered or unexported fields
}
KafKaWriter kafka writer
func NewKafKaWriter ¶
func NewKafKaWriter(conf *ConfKafKaWriter) *KafKaWriter
NewKafKaWriter new kafka writer
func NewKafKaWriterWithWriter ¶
func NewKafKaWriterWithWriter(conf *ConfKafKaWriter, level int) *KafKaWriter
NewKafKaWriterWithWriter new kafka writer with level
type LogConfig ¶
type LogConfig struct { // global level, maybe override by real minimum multi writer level Level string `json:"level" mapstructure:"level"` FullPath bool `json:"full_path" mapstructure:"full_path"` FileWriter ConfFileWriter `json:"file_writer" mapstructure:"file_writer"` ConsoleWriter ConfConsoleWriter `json:"console_writer" mapstructure:"console_writer"` KafKaWriter ConfKafKaWriter `json:"kafka_writer" mapstructure:"kafka_writer"` }
LogConfig log config
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger log struct
type SyslogWriter ¶
type SyslogWriter struct {
// contains filtered or unexported fields
}
SyslogWriter sys log writer
func NewSyslogWriter ¶
func NewSyslogWriter() *SyslogWriter
func (*SyslogWriter) Init ¶
func (w *SyslogWriter) Init() (err error)
func (*SyslogWriter) SetAddr ¶
func (w *SyslogWriter) SetAddr(addr string)
func (*SyslogWriter) SetNetwork ¶
func (w *SyslogWriter) SetNetwork(network string)
func (*SyslogWriter) SetTag ¶
func (w *SyslogWriter) SetTag(tag string)
func (*SyslogWriter) Write ¶
func (w *SyslogWriter) Write(r *Record) (err error)