I am looking at the python logging module to replace custom code, but I cannot decide on where I should call the basicConfig method.
If I develop a module called mymodule which has submodules, it seems to be a good idea to only call basicConfig once in mymodule.
But if I (or someone else) wants to use mymodule in its own module or program and use the logging module, they cannot call basicConfig themselves and are stuck with the options given to basicConfig in mymodule.
I know there are hacks to solve that. But what is the proper way to use basicConfig, where should it be called?
Call it in your program startup code; triggered from a
__name__ == '__main__'test preferably:and put everything you need to do that is not part of your module-the-library into the main function, including logging configuration.