What does exc_info do in a logging call?
roy at panix.com
Thu Feb 23 15:21:25 CET 2012
In http://docs.python.org/release/2.6.7/library/logging.html, it says:
logging.debug(msg[, *args[, **kwargs]])
There are two keyword arguments in kwargs which are inspected: exc_info
which, if it does not evaluate as false, causes exception information to
be added to the logging message. If an exception tuple (in the format
returned by sys.exc_info()) is provided, it is used; otherwise,
sys.exc_info() is called to get the exception information.
I don't get what this is trying to do. I have this code:
f = urllib2.urlopen(url)
except urllib2.HTTPError as ex:
logger.error("Unable to retrieve profile from facebook
(access_token='%r')" % access_token,
which ends up logging:
[...] ERROR _get_profile Unable to retrieve profile from facebook
so what is the exc_info doing? What "exception information" is being
added to the message? Am I just calling this wrong?
More information about the Python-list