开源的高性能 golang 日志库elog
================
https://github.com/starjiang/elog
------------------------------------
global logger model
==================
```
func main() {
flag.Parse()
defer elog.Flush()
for i := 0; i < 100; i++ {
go func() {
elog.Info("hello", "world")
}()
}
time.Sleep(time.Second)
}
```
./example_elog -logToStderr -logLevel=INFO -logFlushTime=3 -logPath=./
LoggerHandler model
===================
```
type TestLogHandler struct {
}
func (lh *TestLogHandler) Write(data []byte) (int, error) {
return os.Stderr.Write(data)
}
func (lh *TestLogHandler) Flush() {
os.Stderr.Write([]byte("flush\n"))
}
func main() {
writer := &TestLogHandler{}
log := elog.NewEasyLogger("INFO", false, 3, writer)
defer log.Flush()
log.Info("hello", "world")
}
```
elog config
=================
-logFlushTime int
log flush time interval,default 3 seconds (default 3)
-logLevel string
log level[DEBUG,INFO,WARN,ERROR,NONE],default INFO level (default "INFO")
-logPath string
log path,default log to current directory (default "./")
-logToStderr
log to stderr,default false
elog rotate file rules
======================
* 1.when file size reach to 1GB,the logger file will be rotate
* 2.rotate files max num is 10
elog high performance
======================
* log to cache buffer then flush to file
* cache buffer size is 1M
* default flush time 3 seconds,-logFlushTime can change flush time interval
* if want close log outputing,-logLevel=NONE can close log outputing
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传