1 Star 1 Fork 2

allan577/go-lib-logger

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
formatter.go 925 Bytes
一键复制 编辑 原始数据 按行查看 历史
allan577 提交于 4年前 . init
package logger
import (
"bytes"
)
// Formatter interface defines a standard log formatter.
// The log formatter is not necessary for built-in loggers. We serialize logs to
// JSON format by default. This interface only provides a simple way to change
// this default behavior.
type Formatter interface {
// Format formats the given log entity into character data and writes it to
// the given buffer. If the error returned is not empty, the log will be discarded
// and the registered log hook will not be triggered. We will output the error
// information to os.Stderr.
Format(Entity, *bytes.Buffer) error
}
// FormatterFunc type defines a log formatter in the form of a function.
type FormatterFunc func(Entity, *bytes.Buffer) error
// Format formats the given log entity into character data and writes it to
// the given buffer.
func (f FormatterFunc) Format(e Entity, b *bytes.Buffer) error {
return f(e, b)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/allan577/go-lib-logger.git
git@gitee.com:allan577/go-lib-logger.git
allan577
go-lib-logger
go-lib-logger
v1.0.0

搜索帮助