Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AsyncLogger ¶
type AsyncLogger struct {
// contains filtered or unexported fields
}
AsyncLogger 用于把日志写入异步队列,然后由后台 goroutine 调用 handle 消费。
该类型同时实现 io.Writer,可直接作为 zap 的写入目标。
func NewAsyncLogger ¶
func NewAsyncLogger(size int, handle func(b []byte)) *AsyncLogger
NewAsyncLogger 创建一个异步写入器。
size 为队列长度;当队列已满时,新日志会被丢弃(不阻塞调用方)。
func (*AsyncLogger) Close ¶ added in v0.2.0
func (l *AsyncLogger) Close()
func (*AsyncLogger) Logger ¶ added in v0.2.0
func (l *AsyncLogger) Logger(b []byte)
func (*AsyncLogger) Sync ¶ added in v0.2.0
func (l *AsyncLogger) Sync() error
type Conf ¶
type Conf struct {
Console bool `json:"console"`
Remote bool `json:"remote"`
Level string `json:"level"`
// contains filtered or unexported fields
}
Conf 是 logger 的配置项 - Console:是否启用控制台输出 - Remote:是否启用远端输出(需要同时提供 handle 才会生效)
Click to show internal directories.
Click to hide internal directories.