logging
v1.3.1-0.20230226091335-a7e8448ec3aa
go.xrfang.cn/logging
Documentation
pkg.go.dev ↗Constants
LevelBrief (3 declarations)
const ( LevelBrief = 0 LevelDebug = 1 LevelTrace = 2 )
Functions
Finish
func Finish()
Init
func Init(path string, mode LogLevel, opts *Options) (err error)
Path
func Path() string
SetLevel
func SetLevel(level LogLevel)
Types
LogHandler
type LogHandler struct {
// contains filtered or unexported fields
}
DefaultHandler
func DefaultHandler() *LogHandler
NewLogger
func NewLogger(path string, mode LogLevel, opts *Options) (*LogHandler, error)
LogHandler.Close
func (lh *LogHandler) Close()
LogHandler.Open
func (lh *LogHandler) Open(name string) Logger
LogHandler.Path
func (lh *LogHandler) Path() string
LogHandler.SetLevel
func (lh *LogHandler) SetLevel(level LogLevel)
LogLevel
type LogLevel = int
Logger
type Logger struct {
// contains filtered or unexported fields
}
Open
func Open(name string) Logger
Logger.Catch
func (l Logger) Catch(handler func(Logger, any))
Logger.Debug
func (l Logger) Debug(mesg string, args ...any)
Logger.Dump
func (l Logger) Dump(data []byte, mesg string, args ...any)
Logger.Flush
func (l Logger) Flush()
Logger.Level
func (l Logger) Level() LogLevel
Logger.Path
func (l Logger) Path() string
Logger.Print
func (l Logger) Print(mesg string, args ...any)
Logger.Trace
func (l Logger) Trace(mesg string, args ...any)
Options
type Options struct {
Split int //切分LOG文件的尺寸,默认为10M
Keep int //历史LOG文件保留数量,默认为10个
Mode os.FileMode //LOG目录的读写权限(已废弃,使用系统umask)
Cache int //LOG在内存中缓存时长(已废弃,固定为1秒)
Queue int //LOG队列长度,默认为64
Shout bool //是否同时输出到STDERR(已废弃)
}
TracedError
type TracedError interface {
Err() error
Error() string
Stack() []string
Describe(string, ...any)
Trace()
}