[Jeremy Hylton wrote] > zLOG does have a nice feature for passing an exception info > to a log call. I'd like to see this as a standard feature, > e.g. > > logger.info("A normal exception occurred", > exc_info=sys.exc_info()) > > The idea is the any of the log calls could also include a > formatted traceback in the log. Ideas I am batting around: MarkH's and Guido's (doesn't allow controlling the level of the message): class Logger: def exception(self, msg, *args): # This is almost identical to error(), but sys.exc_info() is # called, and if available the exception details are appended to # msg. As sys.exc_info() is called, this is only useful in an # exception handler. logger.exception("Like, Oh My God!") # cannot log it at 'info' level Jeremy's: class Logger: def info(self, level, msg, *args, **kwargs): # watch for 'exc_info' in kwargs logger.info("Like, Oh My God!", exc_info=sys.exc_info()) Trent's: class Logger: def exception(self, msg, *args, **kwargs): # watch for 'level' in kwargs logger.exception("Like, Oh My God!", level=logging.INFO) Which do you all prefer? > What's the current status of this PEP? I like the general > outline of stuff, but it feels a little fuzzy. That is, it > seems to present a high-level description and a bunch of > options. I'd like to see the concrete APIs for all of the > objects. The current status is that I have been slowly working on it in private. I agree that the current PEP is fuzzy. > I'd also love to get at least a prototype implementation. > It would be need to replace the zLOG in Zope3 with a new > logging implementation that follows the PEP. Last week (I think) Vinay Sajip posted on python-list that he had a prototype implementation of PEP 282. http://www.red-dove.com/python_logging.html I like what he has and I hope to work with him (merging with what implementation scraps I have) to build the eventual proposed patch for the PEP. I haven't told him this yet though. :) Vinay, what do you think? Trent -- Trent Mick TrentM@ActiveState.com
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4