Documentation
¶
Index ¶
Constants ¶
const ( WhenSecond = iota WhenMinute WhenHour WhenDay )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileHandler ¶
type FileHandler struct {
// contains filtered or unexported fields
}
FileHandler writes log to a file.
func NewFileHandler ¶
func NewFileHandler(fileName string, flag int) (*FileHandler, error)
func (*FileHandler) Close ¶
func (h *FileHandler) Close() error
type NullHandler ¶
type NullHandler struct { }
NullHandler does nothing, it discards anything.
func NewNullHandler ¶
func NewNullHandler() (*NullHandler, error)
func (*NullHandler) Close ¶
func (h *NullHandler) Close()
type RotatingDayMaxFileHandler ¶
type RotatingDayMaxFileHandler struct {
// contains filtered or unexported fields
}
func NewRotatingDayMaxFileHandler ¶
func NewRotatingDayMaxFileHandler(outPath, baseName string, maxBytes int, backupCount int) (*RotatingDayMaxFileHandler, error)
NewRotatingDayMaxFileHandler 每天00点滚动,当超过大小也滚动
func (*RotatingDayMaxFileHandler) Close ¶
func (h *RotatingDayMaxFileHandler) Close() error
type RotatingFileAtDayHandler ¶
type RotatingFileAtDayHandler struct {
// contains filtered or unexported fields
}
func NewDefaultRotatingFileAtDayHandler ¶
func NewDefaultRotatingFileAtDayHandler(baseName string, rollSize int) *RotatingFileAtDayHandler
func NewRotatingFileAtDayHandler ¶
func NewRotatingFileAtDayHandler(baseName string, rollSize int, flushInterval int64, checkEveryN int, syncFlush bool) *RotatingFileAtDayHandler
baseName 日志文件的基本名包含全路径 如 "/tmp/test" rollSize 每写入rollSize字节日志滚动文件 flushInterval 刷新文件写入缓存的间隔 checkEveryN 每写入checkEveryN次 检查文件回滚和缓存刷新 syncFlush == true flushInterval和checkEveryN 失效
func (*RotatingFileAtDayHandler) Close ¶
func (self *RotatingFileAtDayHandler) Close() error
func (*RotatingFileAtDayHandler) Rotate ¶
func (self *RotatingFileAtDayHandler) Rotate()
type RotatingFileHandler ¶
type RotatingFileHandler struct {
// contains filtered or unexported fields
}
RotatingFileHandler writes log a file, if file size exceeds maxBytes, it will backup current file and open a new one.
max backup file number is set by backupCount, it will delete oldest if backups too many.
func NewRotatingFileHandler ¶
func NewRotatingFileHandler(fileName string, maxBytes int, backupCount int) (*RotatingFileHandler, error)
func (*RotatingFileHandler) Close ¶
func (h *RotatingFileHandler) Close() error
type SocketHandler ¶
type SocketHandler struct {
// contains filtered or unexported fields
}
SocketHandler writes log to a connectionl. Network protocol is simple: log length + log | log length + log. log length is uint32, bigendian. you must implement your own log server, maybe you can use logd instead simply.
func NewSocketHandler ¶
func NewSocketHandler(protocol string, addr string) (*SocketHandler, error)
func (*SocketHandler) Close ¶
func (h *SocketHandler) Close() error
type StreamHandler ¶
type StreamHandler struct {
// contains filtered or unexported fields
}
StreamHandler writes logs to a specified io Writer, maybe stdout, stderr, etc...
func NewStreamHandler ¶
func NewStreamHandler(w io.Writer) (*StreamHandler, error)
func (*StreamHandler) Close ¶
func (h *StreamHandler) Close() error
func (*StreamHandler) Rotate ¶
func (h *StreamHandler) Rotate()
type TimeRotatingFileHandler ¶
type TimeRotatingFileHandler struct {
// contains filtered or unexported fields
}
TimeRotatingFileHandler writes log to a file, it will backup current and open a new one, with a period time you sepecified.
refer: http://docs.python.org/2/library/logging.handlers.html. same like python TimedRotatingFileHandler.
func NewTimeRotatingFileHandler ¶
func NewTimeRotatingFileHandler(baseName string, when int8, interval int) (*TimeRotatingFileHandler, error)
func (*TimeRotatingFileHandler) Close ¶
func (h *TimeRotatingFileHandler) Close() error