lumberjack icon indicating copy to clipboard operation
lumberjack copied to clipboard

Post rotate hook

Open hhh0pE opened this issue 6 years ago • 0 comments

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)
}

hhh0pE avatar Feb 07 '19 09:02 hhh0pE