Documentation ¶
Index ¶
- func AddPackageHost(host string)
- func Debug(format string, args ...interface{})
- func Error(format string, args ...interface{})
- func Fatal(format string, args ...interface{})
- func Info(format string, args ...interface{})
- func LoadConfig(config Config)
- func Log(level, format string, args ...interface{})
- func LogWithSkip(skip int, level string, format string, args ...interface{})
- func SetTimeFormat(format string)
- func Warn(format string, args ...interface{})
- type Config
- type EmailWriter
- type Handler
- type Session
- func (s Session) Debug(format string, args ...interface{})
- func (s Session) Error(format string, args ...interface{})
- func (s Session) Fatal(format string, args ...interface{})
- func (s Session) Info(format string, args ...interface{})
- func (s Session) Log(level string, format string, args ...interface{})
- func (s Session) LogWithSkip(skip int, level string, format string, args ...interface{})
- func (s Session) Set(key string, value interface{})
- func (s Session) Warn(format string, args ...interface{})
- type TimeRotateWriter
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddPackageHost ¶
func AddPackageHost(host string)
AddPackageHost add a customized golang package host to known package hosts. While create static local context for logging message formatting, known package hosts is used to cut off GOPATH directory from the path of file. It ensures output compiled in different GOPATH will log with same path of file.
func Debug ¶
func Debug(format string, args ...interface{})
Debug log message with "debug" level and default session.
func Error ¶
func Error(format string, args ...interface{})
Error log message with "error" level and default session.
func Fatal ¶
func Fatal(format string, args ...interface{})
Fatal log message with "fatal" level and default session.
func Info ¶
func Info(format string, args ...interface{})
Info log message with "info" level and default session.
func LoadConfig ¶
func LoadConfig(config Config)
LoadConfig load configuration and setting up the go-logging.
func Log ¶
func Log(level, format string, args ...interface{})
Log log message with default session.
func LogWithSkip ¶
LogWithSkip log message with specified skip
Types ¶
type EmailWriter ¶
type EmailWriter struct { // Email server Server string // Email sender and account name Sender string // Email account password Password string // Email Receivers Receivers []string // Email subject Subject string // the logs arrived after first log in "Delay" duration will be grouped with the first log Delay time.Duration // contains filtered or unexported fields }
EmailWriter group logs and send as email
func (*EmailWriter) Initialize ¶
func (writer *EmailWriter) Initialize()
Initialize setup the writer
type Handler ¶
type Handler struct { // responsible levels Levels []string // format of log message Format string // writers Writers []Writer }
Handler handles format the log message and dispatch it to writers
type Session ¶
type Session map[string]interface{}
Session hold special field of user defined session.
func (Session) LogWithSkip ¶
LogWithSkip log message with specified skip.
type TimeRotateWriter ¶
type TimeRotateWriter struct { sync.Mutex // file path Path string // split file path Split string // rotate interval Interval time.Duration // keep split file duration, the expired split file will be removed Keep time.Duration // contains filtered or unexported fields }
TimeRotateWriter write logs to file and rotate the file Periodically.
func (*TimeRotateWriter) Initialize ¶
func (writer *TimeRotateWriter) Initialize() error
Initialize setup the writer