title: in golang how to store, purge and print log programatically?
body: <p>I have an application with many modules and packages.
  All these use logrus for logging.</p>
  <p>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.</p>
  <p>Here is my requirement</p>
  <p>In every loop the application should write lines in some log storage.</p>
  <p>If the loop succeeds, it should clear this storage and be ready for next loop.</p>
  <p>If there is any problem or error then it should print out all the accumulated log and end.</p>
  <p>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.</p>
  <p>Any idea how should I achieve this?
  Thanks for any guideline in advance.</p>