On this page
logging.getLevelName
Prev: logging.getHandlerNames | Up: logging | Next: logging.getLevelNamesMapping
Rel: logging.addLevelName, logging.basicConfig, logging.BufferingFormatter, logging.captureWarnings
Ref: docs.python.org — logging.getLevelName
Tags: #public #python3 #stdlib #logging
Import
import logging
from logging import getLevelName
Signature & Overview
logging.getLevelName(level)
Return the textual or numeric representation of logging level 'level'.
Usage
import logging
assert logging.getLevelName(logging.WARNING) == "WARNING"
assert logging.getLevelName("WARNING") == 30
Gotchas
- Bidirectional quirk: Passing an
intreturns a name ("WARNING"); passing a name returns anint(30), and an unknown name returns"Level <name>"—prefergetLevelNamesMapping()in Python 3.11+.
REPL Inspect
from logging import getLevelName
help(getLevelName)
Linked from
Related notes
- tuts/python3/stdlib_module/logging/getHandlerNames Linked here; links to this page; shared tags: #logging, #stdlib
- tuts/python3/stdlib_module/logging/getLevelNamesMapping Linked here; links to this page; shared tags: #logging, #stdlib
- tuts/python3/stdlib_module/logging Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/logging/addLevelName Linked here; shared tags: #logging, #stdlib
- tuts/python3/stdlib_module/logging/basicConfig Linked here; shared tags: #logging, #stdlib
- tuts/python3/stdlib_module/logging/BufferingFormatter Linked here; shared tags: #logging, #stdlib
- tuts/python3/stdlib_module/logging/captureWarnings Linked here; shared tags: #logging, #stdlib
- tuts/python3/stdlib_module/logging/critical shared tags: #logging, #stdlib
- tuts/python3/stdlib_module/logging/debug shared tags: #logging, #stdlib
- tuts/python3/stdlib_module/logging/disable shared tags: #logging, #stdlib