Op 02-09-15 om 11:50 schreef Peter Otten: > Antoon Pardon wrote: > >> I am writing an application that will do the necessary logging. >> However I want the level of logging to be deciced by a value >> in a config file. Like the following: >> >> loglevel = WARNING >> >> But I can't find a function that does this. >> >> The reverse is possible with logging.getLevelName. The documentation >> also states this: >> >> Changed in version 3.4: In Python versions earlier than 3.4, this function >> could also be passed a text level, and would return the corresponding >> numeric value of the level. This undocumented behaviour was considered >> a mistake, and was removed in Python 3.4, but reinstated in 3.4.2 due >> to retain backward compatibility. >> >> So what is the supposed correct way to handle this? Preferably one >> that works when additional levels have been introduced. > Why do you want to convert the name into a number? You can use it directly:
Well because that is a recent change and I didn't know about it and I missed it while browsing the documentation. I think this kind of documenation should be part of the proper description and not part of the history. It also doesn't work for everything. Logger.isEnabledFor(lvl) expect a number. But for the moment it serves my needs, so thanks for pointing it out. -- Antoon Pardon. -- https://mail.python.org/mailman/listinfo/python-list