[Python-Dev] transitioning from % to {} formatting (original) (raw)
Vinay Sajip vinay_sajip at yahoo.co.uk
Thu Oct 1 16:37:29 CEST 2009
- Previous message: [Python-Dev] transitioning from % to {} formatting
- Next message: [Python-Dev] transitioning from % to {} formatting
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Antoine Pitrou <solipsis 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", senderaddress) and I want a {}-style logger, I do: logger = logging.getLogger("smtp", style="{}") logger.debug("incoming email from {addr}", addr=senderaddress) (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
- Previous message: [Python-Dev] transitioning from % to {} formatting
- Next message: [Python-Dev] transitioning from % to {} formatting
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]