natefinch / lumberjack

lumberjack is a log rolling package for Go
MIT License
4.81k stars 593 forks source link

Feature Request : Callback before log file deletion #195

Open akshaynotes opened 11 months ago

akshaynotes commented 11 months ago

Problem :

So, my lumberjack logger has rotation based on size (10 MB) and MaxBackups I am using is 32. I am uploading these log files every hour to my server and I delete the log files which are already uploaded. The problem I am facing is if before triggering my cron job the file count exceeds 32 lumberjack will start deleting the files and I am losing those files (cant upload to the server as lumberjack has deleted them).

Feature Request :

I want a callback function which I can pass while initializing logger, which will get triggered just before deleting the logger file callback(string filename){ //1. check if this file was uploaded //2. if not upload //3. if yes -> continue }

Thanks !!