Skip to content

Commit

Permalink
example: log rotate (#3137)
Browse files Browse the repository at this point in the history
  • Loading branch information
hailaz authored Nov 8, 2023
1 parent a17849b commit 5f5b821
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
8 changes: 8 additions & 0 deletions example/os/log/rotate/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[logger]
path = "./log"
file = "{Y-m-d-H-i}.log"
level = "all"
stdout = true
rotateExpire = "1m"
rotateBackupLimit = 4
rotateCheckInterval = "5s"
23 changes: 23 additions & 0 deletions example/os/log/rotate/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package main

import (
"context"
"time"

"github.com/gogf/gf/v2/frame/g"
)

func main() {
ctx := context.Background()
mylog := g.Log()
for {
mylog.Debug(ctx, "debug")
time.Sleep(time.Second)
mylog.Info(ctx, "info")
time.Sleep(time.Second)
mylog.Warning(ctx, "warning")
time.Sleep(time.Second)
mylog.Error(ctx, "error")
time.Sleep(time.Second)
}
}

0 comments on commit 5f5b821

Please sign in to comment.