Suppress newline in Python logging module

后端 未结 4 2038
北海茫月
北海茫月 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:30

    If you wanted to do this you can change the logging handler terminator. I'm using Python 3.4. This was introduced in Python 3.2 as stated by Ninjakannon.

    handler = logging.StreamHandler()
    handler.terminator = ""
    

    When the StreamHandler writes it writes the terminator last.

提交回复
热议问题