Suppress newline in Python logging module

后端 未结 4 2033
北海茫月
北海茫月 2020-12-03 10:00

I\'m trying to replace an ad-hoc logging system with Python\'s logging module. I\'m using the logging system to output progress information for a long task on a single line

4条回答
  •  [愿得一人]
    2020-12-03 10:12

    Let's start with your last question: No, I do not believe it's a good idea. IMO, it hurts the readability of the logfile in the long run.

    I suggest sticking with the logging module and using the '-f' option on your 'tail' command to watch the output from the console. You will probably end up using the FileHandler. Notice that the default argument for 'delay' is False meaning the output won't be buffered.

    If you really needed to suppress newlines, I would recommend creating your own Handler.

提交回复
热议问题