summaryrefslogtreecommitdiffstats
path: root/Doc/library/logging.rst
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2021-03-08 11:16:20 (GMT)
committerGitHub <noreply@github.com>2021-03-08 11:16:20 (GMT)
commitbbba28212ce0f58096a4043f32442c6e727b74fc (patch)
tree7c4bc5795fdf260c15f4f4ac0d45f5d41e291929 /Doc/library/logging.rst
parentc25910a135c2245accadb324b40dd6453015e056 (diff)
downloadcpython-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 'Doc/library/logging.rst')
-rw-r--r--Doc/library/logging.rst25
1 files changed, 17 insertions, 8 deletions
diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst
index 431a584..70a703d 100644
--- a/Doc/library/logging.rst
+++ b/Doc/library/logging.rst
@@ -1113,18 +1113,27 @@ functions.
.. function:: getLevelName(level)
- Returns the textual representation of logging level *level*. If the level is one
- of the predefined levels :const:`CRITICAL`, :const:`ERROR`, :const:`WARNING`,
- :const:`INFO` or :const:`DEBUG` then you get the corresponding string. If you
- have associated levels with names using :func:`addLevelName` then the name you
- have associated with *level* is returned. 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.
+ Returns the textual or numeric representation of logging level *level*.
+
+ If *level* is one of the predefined levels :const:`CRITICAL`, :const:`ERROR`,
+ :const:`WARNING`, :const:`INFO` or :const:`DEBUG` then you get the
+ corresponding string. If you have associated levels with names using
+ :func:`addLevelName` then the name you have associated with *level* is
+ returned. If a numeric value corresponding to one of the defined levels is
+ passed in, the corresponding string representation is returned.
+
+ The *level* parameter also accepts a string representation of the level such
+ as 'INFO'. In such cases, this functions returns the corresponding numeric
+ value of the level.
+
+ If no matching numeric or string value is passed in, the string
+ 'Level %s' % level is returned.
.. note:: Levels are internally integers (as they need to be compared in the
logging logic). This function is used to convert between an integer level
and the level name displayed in the formatted log output by means of the
- ``%(levelname)s`` format specifier (see :ref:`logrecord-attributes`).
+ ``%(levelname)s`` format specifier (see :ref:`logrecord-attributes`), and
+ vice versa.
.. versionchanged:: 3.4
In Python versions earlier than 3.4, this function could also be passed a