[Python-Dev] Proposed change to logging.basicConfig (original) (raw)

Terry Reedy tjreedy at udel.edu
Tue Mar 29 20:48:56 CEST 2011


On 3/29/2011 12:35 PM, Vinay Sajip wrote:

I'm planning a change to logging.basicConfig to add an optional "handlers" keyword argument which defaults to None.

If specified, this should be an iterable of already created handlers, which will be added to the root logger (if it doesn't already have any handlers). Any handler in the iterable which does not have a formatter assigned will be assigned the formatter created by basicConfig. If "handlers" is specified, the "stream", "filename" and "filemode" arguments will be ignored. If any of you can see any problems with this change, or can suggest any improvement to the approach, please respond. I expect to check this change in within the next few days.

I am bothered by mutually exclusive parameters. This is one reason I was glad to see cmp eliminated from list.sort. Quick: what happens if one passes both cmp and key to list.sort? There are three reasonable possibilities. As far as I can read, the answer is not documented.#

I am not familiar with logging, but I wonder if you should have two functions for the two quite different signatures. If not, I think the result of passing conflicting parameters should be something like TypeError: conflicting parameters passed. "In the face of ambiguity, refuse to guess."

Experiment with 2.7 shows that cmp wins. Though too late to change, I

consider this the worst choice of three. I think an exception should be raised. Failing that, I think key should win on the basis that if one adds a 'new-fangled' key func to an existing call with cmp (and forgets to remove cmp), the key func is the one intended. Also, the doc clearly indicates that key is considered superior to cmp.

-- Terry Jan Reedy



More information about the Python-Dev mailing list