diff options
author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-03-08 11:16:20 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-08 11:16:20 (GMT) |
commit | bbba28212ce0f58096a4043f32442c6e727b74fc (patch) | |
tree | 7c4bc5795fdf260c15f4f4ac0d45f5d41e291929 /Lib/logging | |
parent | c25910a135c2245accadb324b40dd6453015e056 (diff) | |
download | cpython-bbba28212ce0f58096a4043f32442c6e727b74fc.zip cpython-bbba28212ce0f58096a4043f32442c6e727b74fc.tar.gz cpython-bbba28212ce0f58096a4043f32442c6e727b74fc.tar.bz2 |
bpo-43353: Document that logging.getLevelName() accepts string representation of logging level. (GH-24693)
[bpo-43353]()
Automerge-Triggered-By: GH:vsajip
Diffstat (limited to 'Lib/logging')
-rw-r--r-- | Lib/logging/__init__.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index 50b7378..411aa53 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -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) |