Documentation
¶
Overview ¶
Package logs 日志操作
Index ¶
- Constants
- func DestroyWithLogs(l Logs)
- func NewRotateFile(format, dir string, size int64) (io.WriteCloser, error)
- func NewSMTP(username, password, subject, host string, sendTo []string) io.Writer
- type HandleFunc
- type Handler
- func MergeHandler(w ...Handler) Handler
- func NewDispatchHandler(d map[Level]Handler) Handler
- func NewJSONHandler(timeLayout string, w ...io.Writer) Handler
- func NewNopHandler() Handler
- func NewTermHandler(timeLayout string, w io.Writer, colors map[Level]colors.Color) Handler
- func NewTextHandler(timeLayout string, w ...io.Writer) Handler
- type Level
- type Logger
- type Logs
- type Options
- type Record
Constants ¶
View Source
const ( Info = logs.LevelInfo Trace = logs.LevelTrace Warn = logs.LevelWarn Debug = logs.LevelDebug Error = logs.LevelError Fatal = logs.LevelFatal )
日志的类别
View Source
const ( MilliLayout = logs.MilliLayout MicroLayout = logs.MicroLayout NanoLayout = logs.NanoLayout )
日志的时间格式
Variables ¶
This section is empty.
Functions ¶
func DestroyWithLogs ¶ added in v0.79.0
func DestroyWithLogs(l Logs)
DestroyWithLogs 回收 [Logs.With] 创建的对象
这是一个非必须的方法,调用可能会有一定的性能提升。需要确保 l 类型的正确性!
func NewRotateFile ¶
func NewRotateFile(format, dir string, size int64) (io.WriteCloser, error)
NewRotateFile 按大小分割的文件日志
参数说明参考 rotate.New
Types ¶
type HandleFunc ¶ added in v0.78.0
type HandleFunc = logs.HandleFunc
type Handler ¶ added in v0.78.0
func MergeHandler ¶ added in v0.78.0
func NewDispatchHandler ¶ added in v0.78.0
func NewJSONHandler ¶ added in v0.78.0
func NewNopHandler ¶ added in v0.78.0
func NewNopHandler() Handler
type Logs ¶
type Logs interface {
INFO() Logger
WARN() Logger
TRACE() Logger
DEBUG() Logger
ERROR() Logger
FATAL() Logger
Logger(Level) Logger
NewRecord(Level) *Record
// With 构建一个带有指定参数的日志对象
With(ps map[string]any) Logs
}
Logs 日志系统接口
Click to show internal directories.
Click to hide internal directories.