I have a very generic function widely used in my program and I want this function to write some logs specifying the file name and line number where it was called (not the useless informatino about where the logging call is).
With the code below:
# myutils.py
def track(iterator, description:str):
logging.info("Very useful information about {description}")
# stuff
yield something
# main.py
import myutils
for item in myutils.track(object1, "first"):
pass
for item in myutils.track(object2, "second"):
pass
I would like to obtain:
main.py:4 Very useful information about first
main.py:7 Very useful information about second
but I obtain:
myutils.py:4 Very useful information about first
myutils.py:4 Very useful information about second
I understant this may not be a good practice but I would like to have the information about which file/line number is calling the track() function, not the logging.info()...
Edit: I don't want a traceback with all called functions, just a simple fix for a more useful logging.