0

I have a script that starts a process and prints another line when it is done:

import logging
import time


def main():
    logger = logging.getLogger()
    logger.setLevel(logging.INFO)
    logger.info("Starting sleep")
    time.sleep(5)
    logger.info("Finished sleep")

main()

This produces the following output:

>>> main()
INFO:root:Starting sleep
INFO:root:Finished sleep

I want it to only print a single line, like it would in the following case:

import logging
import time


def main():
    print("Starting sleep", end="")
    time.sleep(5)
    print(" Finished sleep")

main()

Which results in:

>>> main()
Starting sleep Finished sleep

Can this be done using the python logging module?

Malaber
  • 57
  • 1
  • 8

0 Answers0