Closed bmschmidt closed 8 years ago
I made an error in my example (level is the proper flag for logging.basicConfig, not the R-style logging.level). Editing the comments to avoid confusion.
Also, two more patterns. First, logging doesn't include time by default, so when you're turning it on with logging basicConfig, you can pass a formatting string that includes asctime. i.e.
logging.basicConfig(format="%(levelname)s:%(asctime)s:%(message)s")
Logging a caught exception in Python 2.x:
try:
something()
except Exception, e:
logging.exception(e)
I think any message can be sent to logging.exception, the key part is that it includes a stack trace in the logs.
This is low priority but useful for future contributions to the codebase. The handling of progress writing, error messages, and other problems is currently irregular: in general a stream is written to stderr, but some old debugging code is disappearing entirely.
Peter is right on a previous issue that it would be nice to allow debug logging code to remain around and be toggled on when needed. We'll want to write some errors simultaneously to the log and to stderr, which is possible.
Pasting Peter's comments below and closing the previous issue.