Skip to content

Commit

Permalink
👔 up: rotatefile - update some for print error output
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Jul 5, 2023
1 parent ccc8922 commit 96eedaf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
4 changes: 1 addition & 3 deletions rotatefile/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ func (r *FilesClear) CleanDaemon() {

t := time.NewTicker(flushInterval)
for range t.C {
if err := r.Clean(); err != nil {
printErrln("files-clear: clean old files error:", err)
}
printErrln("files-clear: clean old files error:", r.Clean())
}
}

Expand Down
6 changes: 4 additions & 2 deletions rotatefile/rotatefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ const (
DefaultBackTime uint = 24 * 7
)

func printErrln(args ...any) {
_, _ = fmt.Fprintln(os.Stderr, args...)
func printErrln(pfx string, err error) {
if err != nil {
_, _ = fmt.Fprintln(os.Stderr, pfx, err)
}
}
11 changes: 2 additions & 9 deletions rotatefile/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,7 @@ func (d *Writer) asyncCleanBackups() {

// TODO pref: only start once
go func() {
err := d.Clean()
if err != nil {
printErrln("rotatefile: clean backup files error:", err)
}
printErrln("rotatefile: clean backup files error:", d.Clean())
}()
}

Expand Down Expand Up @@ -373,11 +370,7 @@ func (d *Writer) buildFilterFns(fileName string) []filterFunc {
}

// remove expired files
err := os.Remove(fPath)
if err != nil {
printErrln("rotatefile: remove expired file error:", err)
}

printErrln("rotatefile: remove expired file error:", os.Remove(fPath))
return false
})
}
Expand Down

0 comments on commit 96eedaf

Please sign in to comment.