0

What would be a good way to switch display format of python logging information on StreamHandler?

In a tool, I am working on, python logging information is logged into a file as well as displayed on screen. But due to standard %(asctime)s %(name)-12s %(levelname)-8s %(message)s type format, first 30 characters are occupied by date, time and module information itself and then actual Log message comes.

I am thinking of adding the functionality such that by some key stroke I could hide the information (and also bring it back if required) i.e. something like , CTRL+A hides the date and time display on standard output and CTRL+A again brings it back.

I would like to hear the thoughts or pointers on how to achieve this?

ViFI
  • 971
  • 1
  • 11
  • 27
  • Would you want `CTRL+A` to affect logging or reading the log? It makes more sense to have that functionality when reading the log. But then again, you could write to two log files at all times, with different formats. – zvone Sep 07 '16 at 18:22
  • @zvone , I would want the functionality only when program is running and log is being displayed on screen. I would want actual log file to stay as original with full format. My program takes almost 3-4 hours to finish and during that log is displayed on stdout as well. It is that I want to hide. – ViFI Sep 07 '16 at 18:28

0 Answers0