Severity
Numerical codes for syslog severities.
These constants in this module correspond to those defined in section 4.1.1 of RFC 3164.
log_level_severity ¶
log_level_severity(level_num: int) -> int
Returns corresponding the syslog severity for a given Python log level.
Details about the meaning of the numerical severity values can be found in
section 4.1.1
of RFC 3164.
Even though there are more codes available to syslog, the
EMERGENCY and
NOTICE codes are never returned here,
i.e. it goes straight from
INFORMATIONAL to
WARNING because there is no
equivalent log level in the Python logging module to NOTICE, and
EMERGENCY is unnecessary because no Python script should be able to cause
such severe problems.
Therefore any number above logging.CRITICAL passed will result in
ALERT being returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level_num |
int
|
An integer representing a Python log level number |
required |
Returns:
| Type | Description |
|---|---|
int
|
One of the predefined severity codes that matches the given log level |
Examples:
>>> import logging
>>> log_level_severity(logging.DEBUG)
7
>>> log_level_severity(logging.CRITICAL)
2
>>> log_level_severity(logging.CRITICAL + 1)
1
>>> log_level_severity(999_999)
1