简体   繁体   中英

python - how to log everything without instrumentation

I want to log everything:

  1. Function entered + values of parameters + function exited
  2. Result of every assignment or operation
  3. etc.

Is it possible to log "everything" in a Python execution without instrumenting the code?

Since things are executing in a VM, it should be possible to configure this at the VM level (hopefully?).

I'm using Pycharm but I could do it via commandline it it's necessary.

There's this existing question: How to do logging at function entry, inside and exit in Python but it doesn't address how to log the result of variable assignments.

You would need to use the trace module and/or perhaps the pdb module. They may not give you everything you need, but it would be a starting point. The logging module doesn't work at such a low level as you seem to want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM