summaryrefslogtreecommitdiffstats
path: root/Lib/logging
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2021-03-17 12:15:59 (GMT)
committerGitHub <noreply@github.com>2021-03-17 12:15:59 (GMT)
commit9bdb5802361016704fb3434369741cc6c5e08f02 (patch)
tree885f5d16e8baeb59ba6115902a8d22ebef8c2b44 /Lib/logging
parentdc8558ef302f1b14b45c21abd7451e4fb56b4604 (diff)
downloadcpython-9bdb5802361016704fb3434369741cc6c5e08f02.zip
cpython-9bdb5802361016704fb3434369741cc6c5e08f02.tar.gz
cpython-9bdb5802361016704fb3434369741cc6c5e08f02.tar.bz2
bpo-43353: Document that logging.getLevelName() accepts string representation of logging level. (GH-24693) (#24825)
(cherry picked from commit bbba28212ce0f58096a4043f32442c6e727b74fc) Automerge-Triggered-By: GH:vsajip
Diffstat (limited to 'Lib/logging')
-rw-r--r--Lib/logging/__init__.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index da3f7b1..b393ddd 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)