I need to debug some legacy code and I only want to print some information to a file that will not disturb any other places in the codebase. The most crude way I have found so far is something like:
def my_func():
f = open('/tmp/log.txt', 'a') # help with logging stuff
f.write('...')
# some code
However, I like all the ‘extra’ stuff that the logging module adds in, such as line numbers, time, functions, etc. What might be the best way to add in a local logger to do what a normal logger might do?