[Python-Dev] Re: PEP 282 comments (original) (raw)
Jeremy Hylton jeremy@zope.com
Thu, 21 Mar 2002 00:51:03 -0500
- Previous message: [Python-Dev] Re: PEP 282 comments
- Next message: [Python-Dev] Re: PEP 282 comments
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, 20 Mar 2002 18:13:07 -0800 Trent Mick <trentm@ActiveState.com> wrote:
Touche, I haven't thought about that either and don't know if I am qualified to determine if that is a common enough case. If it is not that common then (forgetting the 'level'-issue for the moment) you have to admit that:
It seems quite plausible to decide to log an exception and then get another trivial exception raised and caught on the way to the logger. You would still want to log the original exception, so passing it explicitly is helpful sometimes.
try: ... except: log.exception("My britches are burning!")
sure is a log nicer than try: ... except: log.logException(sys.excinfo(), "My britches are burning!")
If I would implement debug() and other helper methods, I'd still like to see it as a keyword argument. I assume the various methods would be connected something like this:
class Logger:
def log(self, msg, level, exc=None):
"Log msg at level w/ optional traceback for exc."
def debug(self, msg, exc=None):
self.log(msg, DEBUG_LEVEL, exc)
def exception(self, msg, exc=None):
if exc is None:
exc = sys.exc_info()
self.log(msg, ERROR_LEVEL, exc)
This doesn't seem complicated or particularly slow.
Jeremy
- Previous message: [Python-Dev] Re: PEP 282 comments
- Next message: [Python-Dev] Re: PEP 282 comments
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]