Logging In Pylons
Posted: | 2007-08-14 11:37 |
---|---|
Tags: | Pylons, Python, AuthKit |
Pylons 0.9.6rc1 introduces a new logging mechanism which isn't too well documented at the moment. This is the old method I used before 0.9.6rc1 came out.
In config/middleware.py Add this code at the end:
import logging, sys def setup_logging(key, level=logging.DEBUG, formatter="%(asctime)s %(levelname)s %(module)s %(messages)s" ): log = logging.getLogger(key) console = logging.StreamHandler(sys.stderr) log.setLevel(level) log.addHandler(console)
Then for each log you want recorded you just add this at the bottom of the file:
setup_logging('authkit.authenticate', logging.DEBUG)
This is particularly useful for tracking down problems with AuthKit. You might want to add all these for example:
setup_logging('authkit.authenticate', logging.DEBUG) setup_logging('authkit.authenticate.form', logging.DEBUG) setup_logging('authkit.authenticate.cookie', logging.DEBUG)