I have a Python script that makes use of \'Print\' for printing to stdout. I\'ve recently added logging via Python Logger and would like to make it so these print statement
You really should do that the other way: by adjusting your logging configuration to use print
statements or something else, depending on the settings. Do not overwrite print
behaviour, as some of the settings that may be introduced in the future (eg. by you or by someone else using your module) may actually output it to the stdout
and you will have problems.
There is a handler that is supposed to redirect your log messages to proper stream (file, stdout
or anything else file-like). It is called StreamHandler and it is bundled with logging
module.
So basically in my opinion you should do, what you stated you don't want to do: replace print
statements with actual logging.