I have an application with many modules and packages. All these use logrus for logging.
Application is running in a loop. Loop after loop. When application is has a fatal problem it prints out the log at that step. So I get the log at the error step; but no log about the in between steps that had succeeded.
Here is my requirement
In every loop the application should write lines in some log storage.
If the loop succeeds, it should clear this storage and be ready for next loop.
If there is any problem or error then it should print out all the accumulated log and end.
This way I will get to know the entire loop history when and only when there is an error. If the loop succeeds, there should not be any log printed.
Any idea how should I achieve this? Thanks for any guideline in advance.