@@ -1106,18 +1106,27 @@ functions.
1106
1106
1107
1107
.. function :: getLevelName(level)
1108
1108
1109
- Returns the textual representation of logging level *level *. If the level is one
1110
- of the predefined levels :const: `CRITICAL `, :const: `ERROR `, :const: `WARNING `,
1111
- :const: `INFO ` or :const: `DEBUG ` then you get the corresponding string. If you
1112
- have associated levels with names using :func: `addLevelName ` then the name you
1113
- have associated with *level * is returned. If a numeric value corresponding to one
1114
- of the defined levels is passed in, the corresponding string representation is
1115
- returned. Otherwise, the string 'Level %s' % level is returned.
1109
+ Returns the textual or numeric representation of logging level *level *.
1110
+
1111
+ If *level * is one of the predefined levels :const: `CRITICAL `, :const: `ERROR `,
1112
+ :const: `WARNING `, :const: `INFO ` or :const: `DEBUG ` then you get the
1113
+ corresponding string. If you have associated levels with names using
1114
+ :func: `addLevelName ` then the name you have associated with *level * is
1115
+ returned. If a numeric value corresponding to one of the defined levels is
1116
+ passed in, the corresponding string representation is returned.
1117
+
1118
+ The *level * parameter also accepts a string representation of the level such
1119
+ as 'INFO'. In such cases, this functions returns the corresponding numeric
1120
+ value of the level.
1121
+
1122
+ If no matching numeric or string value is passed in, the string
1123
+ 'Level %s' % level is returned.
1116
1124
1117
1125
.. note :: Levels are internally integers (as they need to be compared in the
1118
1126
logging logic). This function is used to convert between an integer level
1119
1127
and the level name displayed in the formatted log output by means of the
1120
- ``%(levelname)s `` format specifier (see :ref: `logrecord-attributes `).
1128
+ ``%(levelname)s `` format specifier (see :ref: `logrecord-attributes `), and
1129
+ vice versa.
1121
1130
1122
1131
.. versionchanged :: 3.4
1123
1132
In Python versions earlier than 3.4, this function could also be passed a
0 commit comments