dmi_log_level
Synopsis
#include <opendmi/log.h>
typedef enum dmi_log_level {
DMI_LOG_INVALID = -1,
DMI_LOG_ERROR,
DMI_LOG_WARNING,
DMI_LOG_NOTICE,
DMI_LOG_INFO,
DMI_LOG_DEBUG
} dmi_log_level_t;
const char *dmi_log_level_name(dmi_log_level_t value);
dmi_log_level_t dmi_log_level_find(const char *code);
Description
The dmi_log_level_t enumeration tells the severity of a log message, see
dmi_log, and the least severe level of the messages a context writes to
its handler, see dmi_set_log_level. Levels are ordered from the most
severe one to the least, so that a level is less severe than another one if
its value is greater.
The dmi_log_level_name function returns the name of a level, as the command
line tool prints it before a message, e.g. WARNING. The name is translated
to the locale set with dmi_set_locale if the library is built with ICU4C
support and the locale has a translation of it, and is in English otherwise.
The dmi_log_level_find function returns the level whose code is code,
e.g. to parse a level given on the command line. The codes are the names of
the levels in lower case: error, warning, notice, info and debug.
Codes are compared exactly, case included, and are never translated.
Return value
The dmi_log_level_name function returns the name of the level, or
UNKNOWN if the value is not a level, e.g. DMI_LOG_INVALID, so that a log
record can always be prefixed with it, unlike the other *_name functions,
which return nullptr then. The string
belongs to the library and must not be modified or freed; a translated name
may become invalid once the locale is changed.
The dmi_log_level_find function returns the level, or DMI_LOG_INVALID if
code is nullptr or no level has the code.