Skip to content

Commit

Permalink
chore: update readme, update some preivew images
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Jun 13, 2022
1 parent 3a5bac2 commit f282d45
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 8 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
- `rotate_file` outputs logs to the specified file, and supports splitting files by time and size, and `buffer` buffered writing is enabled by default
- See ./handler folder for more built-in implementations
- Output logs to file
- Support enabling buffers for log writing
- Support splitting log files by time and size
- Support configuration to compress log files via gzip
- Support enabling `buffer` for log writing
- Support splitting log files by `time` and `size`
- Support configuration to compress log files via `gzip`
- Support clean old log files by `BackupNum` `BackupTime`

> NEW: `v0.3.0` discards the various handlers that were originally implemented, and the unified abstraction is
Expand Down
2 changes: 1 addition & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
- 输出日志到指定文件
- 支持启用 `buffer` 缓冲日志写入
- 支持按时间、按大小分割文件
- 支持配置通过gzip压缩日志文件
- 支持配置通过 `gzip` 压缩日志文件
- 支持清理旧日志文件 配置: `BackupNum` `BackupTime`

> NEW: `v0.3.0` 废弃原来实现的纷乱的各种handler,统一抽象为
Expand Down
17 changes: 17 additions & 0 deletions _example/diff-with-zap-zerolog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# diff with zap, zerolog

是的,zap 非常快速。

但是有一点问题:

- 配置起来稍显复杂
- 没有内置切割文件处理和文件清理
- 自定义扩展性不是很好

Yes, zap is very fast.

But there is a little problem:

- Slightly complicated to configure
- No built-in cutting file handling, file cleanup
- Custom extensibility is not very good
4 changes: 2 additions & 2 deletions _example/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ go 1.17

require (
github.com/golang/glog v1.0.0
github.com/gookit/slog v0.3.1
github.com/gookit/goutil v0.5.2
github.com/gookit/slog v0.3.2
github.com/phuslu/log v1.0.67
github.com/rs/zerolog v1.26.1
github.com/sirupsen/logrus v1.8.1
Expand All @@ -14,7 +15,6 @@ require (

require (
github.com/gookit/color v1.5.0 // indirect
github.com/gookit/goutil v0.5.2 // indirect
github.com/gookit/gsr v0.0.7 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
Expand Down
6 changes: 4 additions & 2 deletions _example/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s=
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
github.com/syyongx/llog v0.0.0-20200222114215-e8f9f86ac0a3 h1:nmgdEP0lq+35kbN1HDFrut7+XAf6SOpy0xP+emR1tsc=
github.com/syyongx/llog v0.0.0-20200222114215-e8f9f86ac0a3/go.mod h1:/UHX9iEXv+5L8cOd0OM8DH6ln3/PGtRbCGbCk8uTStQ=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
Expand Down Expand Up @@ -99,5 +100,6 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Binary file modified _example/images/console-log-all-level.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _example/images/slog-all-level.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions _example/slog_all_level.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package main

import (
"errors"

"github.com/gookit/goutil/errorx"
"github.com/gookit/slog"
"github.com/gookit/slog/handler"
)

// run: go run ./_example/slog_all_level.go
func main() {
l := slog.NewWithConfig(func(l *slog.Logger) {
l.DoNothingOnPanicFatal()
})

l.AddHandler(handler.NewConsoleHandler(slog.AllLevels))
printAllLevel(l, "this a", "log", "message")
}

func printAllLevel(l *slog.Logger, args ...interface{}) {
l.Debug(args...)
l.Info(args...)
l.Warn(args...)
l.Error(args...)
l.Print(args...)
l.Println(args...)
l.Fatal(args...)
l.Fatalln(args...)
l.Panic(args...)
l.Panicln(args...)

l.Trace(args...)
l.Notice(args...)
l.ErrorT(errors.New("a error object"))
l.ErrorT(errorx.New("error with stack info"))
}

0 comments on commit f282d45

Please sign in to comment.