natefinch / lumberjack

lumberjack is a log rolling package for Go
MIT License
4.86k stars 598 forks source link

Compressing rolled files #13

Closed mholt closed 7 years ago

mholt commented 9 years ago

How would you feel about an option to gzip rolled log files?

natefinch commented 9 years ago

I think that would be very useful. I think giving lumberjack a func (io.Writer) io.WriteCloser that it could use to wrap a file and use to write the backups would be good (so people can provide their own favorite zip algorithm). We could add zipping to the tasks we do on old log files in the cleanup function (doing the actual compression in a separate goroutine to a temp file and then replace the non-compressed backup atomically with the compressed version... see natefinch/atomic for atomic replacements on platforms other than Linux... and ug, I need to actually fix up that repo so that it has like, tests and such).

acmacalister commented 9 years ago

That sounds like a good plan to me. I like the idea of the atomic writing for when we compression the old log files, so we ensure we don't lose any of the files or data.