I am developping a python application and I would like to include a very detailed stack info in case of exceptions, including all local variables. This is what is done in Django

I have set up the Python (in Python 3) log and with logger.debug (' error in knitting ',exc_info = True, stack_info = True, extra = dicte) I get the stack trace but not the list of internal variables and their content. How can I do this?

what I would like to get is th following:

▼ Local vars Variable Value args



{'tech_number': 108}




1 Answers

Ke Zhang On

I don't really understand your question. But I think you could put whatever you want into extra as a python dict. Then you need

  1. overwrite your record.message in function format
  2. set format to your logger

Here is part of the code as example Link