A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-March/021538.html below:

[Python-Dev] Re: PEP 282 comments

[Python-Dev] Re: PEP 282 commentsJeremy Hylton jeremy@zope.com
Thu, 21 Mar 2002 00:51:03 -0500
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.exc_info(), "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



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