lumberjack
lumberjack copied to clipboard
Post rotate hook
Hello.
I need to run a function after logFile has been rotated. I don't see any way to do it in the code, so I implemented it myself.
There are two new callbacks: AfterCompressFunc (filepath string) BeforeDeleteFunc(filepath string) bool
First is async, second is blocking. BeforeDeleteFunc also can cancel file deleting by return FALSE, so it adds an ability to filter deleting files or do something before they will be deleted.
Both can be used to gracefully handle new log rotated, like:
lumberJackLogger.AfterCompressFunc = func(filepath string) {
log.Println("AfterCompressFunc "+filepath)
sendArchiveToServer(filepath)
}