What I want: To use the logging library instead of print statements, everywhere. Some times it is nice to not terminate with a new line. Consider this simplified example:
for file in files:
print('Loading {}'.format(file), end='', flush=True)
try:
data = load(file)
print('\rLoaded {}'.format(file))
except:
print('\rFailed loading {}'.format(file))
The obvious way would be to use:
handler = logging.StreamHandler()
handler.terminator = ""
However, I do not want to add a handler to my library, and I do want the default behaviour of my main logger to be to terminate with a new line. Terminating with "" feels like it should be the exception, rather than the rule.
Is there a way that I could do something like:
logger.info(msg, terminator="")
without having to create a lot of subclasses to the logging module?
Is my take on the problem reasonable, or is there a better way of handling this?