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/2009-October/092448.html below:

[Python-Dev] transitioning from % to {} formatting

[Python-Dev] transitioning from % to {} formattingVinay Sajip vinay_sajip at yahoo.co.uk
Thu Oct 1 16:37:29 CEST 2009
Antoine Pitrou <solipsis <at> pitrou.net> writes:

> There's another possibility, which is to build the wrapping directly around the
> logger. That is, if I want a %-style logger, I do:
> 
>    logger = logging.getLogger("smtp")
>    logger.debug("incoming email from %s", sender_address)
> 
> and I want a {}-style logger, I do:
> 
>    logger = logging.getLogger("smtp", style="{}")
>    logger.debug("incoming email from {addr}", addr=sender_address)
> 
> (of course, different users of the "smtp" logger can request different
> formatting styles when calling getLogger().)

There's a LoggerAdapter class already in the system which is used to wrap
loggers so that additional contextual information (e.g. network or database
connection information) can be added to logs. The LoggerAdapter could fulfill
this "wrapping" function.

> We could combine the various proposals to give users flexible APIs. Of course,
> it generally smells of "there's more than one way to do it".

Yeah, that bothers me too.

> > It's the Rumsfeldian "We don't know what we don't know" 
> 
> Is this guy in the Python community? 

Not sure, but I believe he's a piece of work and not a guy to get on the wrong
side of ;-)

Regards,

Vinay Sajip

More information about the Python-Dev mailing list

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