handler

package
v0.0.0-...-0b7460b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
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

func (*FileHandler) Write

func (h *FileHandler) Write(b []byte) (n int, err 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()

func (*NullHandler) Write

func (h *NullHandler) Write(b []byte) (n int, err error)

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

func (*RotatingDayMaxFileHandler) Write

func (h *RotatingDayMaxFileHandler) Write(p []byte) (n int, err 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()

func (*RotatingFileAtDayHandler) Write

func (self *RotatingFileAtDayHandler) Write(b []byte) (int, error)

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

func (*RotatingFileHandler) Write

func (h *RotatingFileHandler) Write(p []byte) (n int, err 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

func (*SocketHandler) Write

func (h *SocketHandler) Write(p []byte) (n int, err 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()

func (*StreamHandler) Write

func (h *StreamHandler) Write(b []byte) (n int, err error)

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

func (*TimeRotatingFileHandler) Write

func (h *TimeRotatingFileHandler) Write(b []byte) (n int, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL