Logging oddity: handlers mandatory in every single logger?

Jean-Michel Pichavant jeanmichel at sequans.com
Wed Feb 3 11:50:19 CET 2010


>> The reason is that log takes an *int* as first argument that defines the logging level. You gave a string. So There is definitely a reason for it to be incorrect.
>>     
> That's not a reason, that's just what currently happens. I know it doesn't work, and I know why, I went and checked the code. But there's no fundamental reason why you couldn't use a level *name* instead of a level code. And indeed, in most parts of logging you can (including but not limited to the configuration of handlers and loggers)
>
>   
You don't neeed to check the code for that ! It is written in the 
documentation. The logging module designer choose to ask for a level, 
not a level name, possibly because 2 different levels can have the same 
name.


>>
>> the field handlers must be defined even if empty.
>>     
> Ah, interesting, I didn't think it could be defined as empty.
>
> Which makes the requirement to have an empty ``handler`` completely nonsensical, doesn't it?
>
>   

'completeley nonsensical' is overstating.  It make sense to state that 
your handler list is empty, when it is empty. Having no field at all 
could possibly mean the same, but it's often better that have one 
consisten way to interface with a module.


JM



More information about the Python-list mailing list