-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
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
The outdated log file is not deleted when the rorate is on #14
Comments
Oh ,forget the clog version. I once got it work with v2.0.0 at 2019/11/26. |
Thank you for filing this issue! I can confirm the bug is that the "delete" logic is only triggered once at start. |
Thanks for your reply. Currently, I wrote a workaround for it. But maybe it's better to handle it in the clog library. go func() {
for {
select {
case <-ctx.Done():
return
case <-time.After(time.Hour * 24):
if err := log.NewFile(conf); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
}
}() |
Can we call if needsRotate {
_ = l.file.Close()
if err := os.Rename(l.filename, rotateFilename(l.filename, rotateDate.Format(simpleDateFormat))); err != nil {
return bytesWrote, fmt.Errorf("rename rotated file %q: %v", l.filename, err)
}
if err := l.initFile(); err != nil {
return bytesWrote, fmt.Errorf("init file %q: %v", l.filename, err)
}
l.openDay = now.Day()
l.currentSize = 0
l.currentLines = 0
//delete outdated file in here
if err := l.deleteOutdatedFiles(); err != nil {
return bytesWrote, fmt.Errorf("delete outdated file: %v", err)
}
} |
I use clog as logging library in my project.
I meet an weird issue that the outdated log file is not deleted when rotate is on.
My go version is
clog was initialled with the code below:
The daemon is running since last Thursday.
The
MaxDays
is set to1
, but the old log is still there.Did I make anything wrong or miss anything ?
Thanks
The text was updated successfully, but these errors were encountered: