bpo-43353: Document that logging.getLevelName() accepts string representation of logging level. (GH-24693)

[bpo-43353]()

Automerge-Triggered-By: GH:vsajip
This commit is contained in:
Mariusz Felisiak 2021-03-08 12:16:20 +01:00 committed by GitHub
parent c25910a135
commit bbba28212c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 10 deletions

View file

@ -118,7 +118,7 @@ _nameToLevel = {
def getLevelName(level):
"""
Return the textual representation of logging level 'level'.
Return the textual or numeric representation of logging level 'level'.
If the level is one of the predefined levels (CRITICAL, ERROR, WARNING,
INFO, DEBUG) then you get the corresponding string. If you have
@ -128,7 +128,11 @@ def getLevelName(level):
If a numeric value corresponding to one of the defined levels is passed
in, the corresponding string representation is returned.
Otherwise, the string "Level %s" % level is returned.
If a string representation of the level is passed in, the corresponding
numeric value is returned.
If no matching numeric or string value is passed in, the string
'Level %s' % level is returned.
"""
# See Issues #22386, #27937 and #29220 for why it's this way
result = _levelToName.get(level)