I would like to inject the arguments of a method which fire an error level log into the log.
I looked at this question and I think the inspect library could be a good choice to get the arguments of the method: Getting method parameter names in python
import inspect
def add(x,y):
frame = inspect.currentframe()
try:
print(frame.f_locals)
finally:
del frame
return x+y
Running: add(4,5)
Returns: {'frame': , 'y': 5, 'x': 4}
Though ideally I would only like to call the above inspect code to add the info to the error level logs automatically and only when they are called somehow overwriting the error logs.