-
Notifications
You must be signed in to change notification settings - Fork 144
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
support log rotate #133
Comments
I run |
Log rotate does not need to be supported. Use the lumberjsack logger to create a rotating log output stream |
lumberjsack logger is based on the file size. I have implemented a log rotating based on time, TimedRotatingFile in the sub-package You just need to implement an adapter for type closingHandler struct {
io.WriteCloser
log15.Handler
}
func (h *closingHandler) Close() error {
return h.WriteCloser.Close()
}
// The handler adapter for log15.
func TimedRotatingFileHandler(fmtr log15.Format, filename string, backupCount, interval int) (h log15.Handler, err error) {
defer func() {
if _err := recover(); _err != nil {
err = _err.(error)
return
}
}()
_h := handler.NewTimedRotatingFile(filename)
_h.SetBackupCount(backupCount).SetInterval(interval)
return closingHandler{_h, log15.StreamHandler(_h, fmtr)}, nil
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dear
can you support auto create new file by date, for example:
after call
log.Must.FileHandler("filename", log.LogfmtFormat())
,log15 will create file named "filename + Date" at different dates,
such as: 2017-07-25 write log to file
filename-2017-07-25.log
, and 2017-07-26 write log to filefilename-2017-07-26.log
And auto remove expired log file.
Thanks
The text was updated successfully, but these errors were encountered: