I have a custom module called bar.py, which I import in some of my scripts. It is actually imported via pip install from the pypi index. That bar.py module looks like this (this is actually an oversimplified example of what I actually have so I can ringfence my doubt here.
import logging
def do_bar_logged():
logging.INFO('START DOING SOMETHING')
do_bar()
logging.INFO('END DOING SOMETHING')
One of the scripts in which I import bar's do_bar_logged is called foo.py. It looks something like this.
import logging
from bar import do_bar_logged # I need to install via pip bar before being able to import this, just like a regular module.
def main():
logging.INFO('START CALLING DO_BAR')
do_bar_logged()
logging.INFO('END CALLING DO_BAR')
My question here is: would it be possible to have both loggings pointing to the same file without harcoding anything?
loggingwhich made specifically for this. Take a look on Logging HOWTO.printcalls.