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 _______________________________________________ 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