Hello,

> Well, it's less readable, as I said in parentheses. It would work, of course.
> And the special wrappers needn't be too intrusive:
> 
> __ = BraceMessage
> 
> logger.debug(__("Message with {0} {1}", 1, "argument"))

Ah, I hadn't thought about that. It looks a bit less awful indeed.
I'm of the opinion, however, that %-formatting should remain the default and
shouldn't need a wrapper.

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().)

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".

> It's the Rumsfeldian "We don't know what we don't know" 

Is this guy in the Python community? :-)

> I'm just trying to think ahead, and can't claim to have got a definitive 
> answer
> up my sleeve.

Sure, we have some time until 2.7/3.2 anyway.

Regards

Antoine.


_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to