Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2f1cd8a

Browse files
committed
Issue #22436: Improved documentation for getEffectiveLevel() and getLevelName().
1 parent 15e4833 commit 2f1cd8a

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

Doc/library/logging.rst

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ is the module's name in the Python package namespace.
118118
.. versionchanged:: 3.2
119119
The *lvl* parameter now accepts a string representation of the
120120
level such as 'INFO' as an alternative to the integer constants
121-
such as :const:`INFO`.
121+
such as :const:`INFO`. Note, however, that levels are internally stored
122+
as integers, and methods such as e.g. :meth:`getEffectiveLevel` and
123+
:meth:`isEnabledFor` will return/expect to be passed integers.
122124

123125

124126
.. method:: Logger.isEnabledFor(lvl)
@@ -134,7 +136,9 @@ is the module's name in the Python package namespace.
134136
Indicates the effective level for this logger. If a value other than
135137
:const:`NOTSET` has been set using :meth:`setLevel`, it is returned. Otherwise,
136138
the hierarchy is traversed towards the root until a value other than
137-
:const:`NOTSET` is found, and that value is returned.
139+
:const:`NOTSET` is found, and that value is returned. The value returned is
140+
an integer, typically one of :const:`logging.DEBUG`, :const:`logging.INFO`
141+
etc.
138142

139143

140144
.. method:: Logger.getChild(suffix)
@@ -1049,6 +1053,11 @@ functions.
10491053
of the defined levels is passed in, the corresponding string representation is
10501054
returned. Otherwise, the string 'Level %s' % lvl is returned.
10511055

1056+
.. note:: Levels are internally integers (as they need to be compared in the
1057+
logging logic). This function is used to convert between an integer level
1058+
and the level name displayed in the formatted log output by means of the
1059+
``%(levelname)s`` format specifier (see :ref:`logrecord-attributes`).
1060+
10521061
.. versionchanged:: 3.4
10531062
In Python versions earlier than 3.4, this function could also be passed a
10541063
text level, and would return the corresponding numeric value of the level.

0 commit comments

Comments
 (0)