We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
System (please complete the following information):
macOS
1.21
0.5.3
Describe the bug
运行时 slog 不会根据 BackupNum 参数限制文件备份文件的数量,开启压缩选项后在运行过程中也不会将备份的文件进行压缩。 当重新启动后 slog 才会移除多余的备份文件,及压缩备份文件
To Reproduce
以下程序将每隔 30 秒产生一个备份文件,持续 10 分钟。允许的最大备份数据为 5 并开启压缩功能。
package main import ( "context" "fmt" "time" "github.com/gookit/slog" "github.com/gookit/slog/handler" "github.com/gookit/slog/rotatefile" ) const pth = "./logs/main.log" func main() { log := slog.New() h, err := handler.NewTimeRotateFileHandler( pth, rotatefile.RotateTime((time.Second * 30).Seconds()), handler.WithBuffSize(0), handler.WithBackupNum(5), handler.WithCompress(true), ) if err != nil { panic(err) } log.AddHandler(h) ctx, _ := context.WithTimeout(context.Background(), time.Minute*10) go func() { for { select { case <-ctx.Done(): return case <-time.After(time.Second): log.Info("Log " + time.Now().String()) } } }() <-ctx.Done() fmt.Println("Exit.") }
Expected behavior
应该在运行时就限制相应的备份数量及压缩备份文件,而不是在重新启动后。
Screenshots
The text was updated successfully, but these errors were encountered:
感谢报告,我测试一下
Sorry, something went wrong.
🐛 fix: fix the async clean old log files not working. see issues #111
b8c0984
有个BUG修复了,可以拉取最新版本试试。
Update slog v0.5.4 to fix rotation issue. Thanks slog team.
323688d
FYI gookit/slog#111
辛苦了,测试可以了!
inhere
No branches or pull requests
System (please complete the following information):
macOS
1.21
0.5.3
Describe the bug
运行时 slog 不会根据 BackupNum 参数限制文件备份文件的数量,开启压缩选项后在运行过程中也不会将备份的文件进行压缩。
当重新启动后 slog 才会移除多余的备份文件,及压缩备份文件
To Reproduce
以下程序将每隔 30 秒产生一个备份文件,持续 10 分钟。允许的最大备份数据为 5 并开启压缩功能。
Expected behavior
应该在运行时就限制相应的备份数量及压缩备份文件,而不是在重新启动后。
Screenshots
The text was updated successfully, but these errors were encountered: