stumpless 2.2.0
Loading...
Searching...
No Matches
severity.h File Reference

Severity codes for classifying log entries. More...

Go to the source code of this file.

Macros

#define STUMPLESS_SEVERITY_MASK(SEVERITY)   ( 1 << ( SEVERITY ) )
 Creates a severity mask for the provided severity.
 
#define STUMPLESS_SEVERITY_MASK_UPTO(SEVERITY)   ( ( 1 << ( ( SEVERITY ) + 1 ) ) - 1 )
 Creates a severity mask from EMERG up to the provided severity.
 
#define STUMPLESS_SEVERITY_EMERG_VALUE   0
 Severity code value for EMERG log entries.
 
#define STUMPLESS_SEVERITY_ALERT_VALUE   1
 Severity code value for ALERT log entries.
 
#define STUMPLESS_SEVERITY_CRIT_VALUE   2
 Severity code value for CRIT log entries.
 
#define STUMPLESS_SEVERITY_ERR_VALUE   3
 Severity code value for ERR log entries.
 
#define STUMPLESS_SEVERITY_WARNING_VALUE   4
 Severity code value for WARNING log entries.
 
#define STUMPLESS_SEVERITY_NOTICE_VALUE   5
 Severity code value for NOTICE log entries.
 
#define STUMPLESS_SEVERITY_INFO_VALUE   6
 Severity code value for INFO log entries.
 
#define STUMPLESS_SEVERITY_DEBUG_VALUE   7
 Severity code value for DEBUG log entries.
 
#define STUMPLESS_SEVERITY_TRACE_VALUE   STUMPLESS_SEVERITY_DEBUG_VALUE
 Equivalent to the DEBUG severity code value.
 
#define STUMPLESS_FOREACH_SEVERITY(ACTION)
 A macro function that runs the provided action once for each severity, providing the symbol and value.
 
#define STUMPLESS_SEVERITY_TRACE   STUMPLESS_SEVERITY_DEBUG
 Equivalent to the DEBUG severity.
 

Enumerations

enum  stumpless_severity { STUMPLESS_GENERATE_ENUM =( STUMPLESS_SEVERITY_EMERG, 0 ) STUMPLESS_GENERATE_ENUM( STUMPLESS_SEVERITY_ALERT, 1 ) STUMPLESS_GENERATE_ENUM( STUMPLESS_SEVERITY_CRIT, 2 ) STUMPLESS_GENERATE_ENUM( STUMPLESS_SEVERITY_ERR, 3 ) STUMPLESS_GENERATE_ENUM( STUMPLESS_SEVERITY_WARNING, 4 ) STUMPLESS_GENERATE_ENUM( STUMPLESS_SEVERITY_NOTICE, 5 ) STUMPLESS_GENERATE_ENUM( STUMPLESS_SEVERITY_INFO, 6 ) STUMPLESS_GENERATE_ENUM( STUMPLESS_SEVERITY_DEBUG, 7 ) }
 All possible severity codes available to log entries. More...
 

Functions

STUMPLESS_PUBLIC_FUNCTION const char * stumpless_get_severity_string (enum stumpless_severity severity)
 Gets the string representation of the given severity.
 
STUMPLESS_PUBLIC_FUNCTION enum stumpless_severity stumpless_get_severity_enum (const char *severity_string)
 Gets the enum value corresponding to the given severity string.
 
STUMPLESS_PUBLIC_FUNCTION enum stumpless_severity stumpless_get_severity_enum_from_buffer (const char *buffer, size_t length)
 Gets the enum value corresponding to the given severity string in a buffer.
 

Detailed Description

Severity codes for classifying log entries.

See RFC 5424 section 6.2.1 for details on these values. Severities are defined to be compatible with the syslog.h header if it is found on the system. Otherwise, they are defined as closely as possible to the RFC 5424 specification.

Macro Definition Documentation

◆ STUMPLESS_FOREACH_SEVERITY

#define STUMPLESS_FOREACH_SEVERITY ( ACTION)
Value:
\
ACTION( STUMPLESS_SEVERITY_EMERG, STUMPLESS_SEVERITY_EMERG_VALUE ) \
\
ACTION( STUMPLESS_SEVERITY_ALERT, STUMPLESS_SEVERITY_ALERT_VALUE ) \
\
ACTION( STUMPLESS_SEVERITY_CRIT, STUMPLESS_SEVERITY_CRIT_VALUE ) \
\
ACTION( STUMPLESS_SEVERITY_ERR, STUMPLESS_SEVERITY_ERR_VALUE ) \
\
ACTION( STUMPLESS_SEVERITY_WARNING, STUMPLESS_SEVERITY_WARNING_VALUE ) \
\
ACTION( STUMPLESS_SEVERITY_NOTICE, STUMPLESS_SEVERITY_NOTICE_VALUE ) \
\
ACTION( STUMPLESS_SEVERITY_INFO, STUMPLESS_SEVERITY_INFO_VALUE ) \
\
ACTION( STUMPLESS_SEVERITY_DEBUG, STUMPLESS_SEVERITY_DEBUG_VALUE )
#define STUMPLESS_SEVERITY_INFO_VALUE
Severity code value for INFO log entries.
Definition severity.h:126
#define STUMPLESS_SEVERITY_WARNING_VALUE
Severity code value for WARNING log entries.
Definition severity.h:104
#define STUMPLESS_SEVERITY_NOTICE_VALUE
Severity code value for NOTICE log entries.
Definition severity.h:115
#define STUMPLESS_SEVERITY_EMERG_VALUE
Severity code value for EMERG log entries.
Definition severity.h:60
#define STUMPLESS_SEVERITY_DEBUG_VALUE
Severity code value for DEBUG log entries.
Definition severity.h:137
#define STUMPLESS_SEVERITY_ERR_VALUE
Severity code value for ERR log entries.
Definition severity.h:93
#define STUMPLESS_SEVERITY_ALERT_VALUE
Severity code value for ALERT log entries.
Definition severity.h:71
#define STUMPLESS_SEVERITY_CRIT_VALUE
Severity code value for CRIT log entries.
Definition severity.h:82

A macro function that runs the provided action once for each severity, providing the symbol and value.

The action must take two arguments, the first being the symbol name of the severity, and the second the numeric value of the severity.

Since
release v2.0.0.

◆ STUMPLESS_SEVERITY_ALERT_VALUE

#define STUMPLESS_SEVERITY_ALERT_VALUE   1

Severity code value for ALERT log entries.

Since
release v2.0.0.

◆ STUMPLESS_SEVERITY_CRIT_VALUE

#define STUMPLESS_SEVERITY_CRIT_VALUE   2

Severity code value for CRIT log entries.

Since
release v2.0.0.

◆ STUMPLESS_SEVERITY_DEBUG_VALUE

#define STUMPLESS_SEVERITY_DEBUG_VALUE   7

Severity code value for DEBUG log entries.

Since
release v2.0.0.

◆ STUMPLESS_SEVERITY_EMERG_VALUE

#define STUMPLESS_SEVERITY_EMERG_VALUE   0

Severity code value for EMERG log entries.

Since
release v2.0.0.

◆ STUMPLESS_SEVERITY_ERR_VALUE

#define STUMPLESS_SEVERITY_ERR_VALUE   3

Severity code value for ERR log entries.

Since
release v2.0.0.

◆ STUMPLESS_SEVERITY_INFO_VALUE

#define STUMPLESS_SEVERITY_INFO_VALUE   6

Severity code value for INFO log entries.

Since
release v2.0.0.

◆ STUMPLESS_SEVERITY_MASK

#define STUMPLESS_SEVERITY_MASK ( SEVERITY)    ( 1 << ( SEVERITY ) )

Creates a severity mask for the provided severity.

Examples
filter_example.c.

◆ STUMPLESS_SEVERITY_MASK_UPTO

#define STUMPLESS_SEVERITY_MASK_UPTO ( SEVERITY)    ( ( 1 << ( ( SEVERITY ) + 1 ) ) - 1 )

Creates a severity mask from EMERG up to the provided severity.

Examples
chain_example.c, and filter_example.c.

◆ STUMPLESS_SEVERITY_NOTICE_VALUE

#define STUMPLESS_SEVERITY_NOTICE_VALUE   5

Severity code value for NOTICE log entries.

Since
release v2.0.0.

◆ STUMPLESS_SEVERITY_TRACE

#define STUMPLESS_SEVERITY_TRACE   STUMPLESS_SEVERITY_DEBUG

Equivalent to the DEBUG severity.

Trace level messages include extra information, but do not have a distinct severity value in log entries.

Since
release v2.1.0

◆ STUMPLESS_SEVERITY_TRACE_VALUE

#define STUMPLESS_SEVERITY_TRACE_VALUE   STUMPLESS_SEVERITY_DEBUG_VALUE

Equivalent to the DEBUG severity code value.

Trace level messages include extra information, but do not have a distinct severity value in log entries.

Since
release v2.1.0

◆ STUMPLESS_SEVERITY_WARNING_VALUE

#define STUMPLESS_SEVERITY_WARNING_VALUE   4

Severity code value for WARNING log entries.

Since
release v2.0.0.

Enumeration Type Documentation

◆ stumpless_severity

All possible severity codes available to log entries.

In versions prior to 2.0.0, these values were simply #define symbols. They have been changed to an enum to clearly convey proper usage.

See STUMPLESS_FOREACH_SEVERITY() and STUMPLESS_GENERATE_ENUM() for how the enumeration is actually defined.

Since
release v2.0.0.
Enumerator
STUMPLESS_GENERATE_ENUM 

Emergency: system is unusable.

Function Documentation

◆ stumpless_get_severity_enum()

STUMPLESS_PUBLIC_FUNCTION enum stumpless_severity stumpless_get_severity_enum ( const char * severity_string)

Gets the enum value corresponding to the given severity string.

Thread Safety: MT-Safe This function is thread safe.

Async Signal Safety: AS-Safe This function is safe to call from signal handlers.

Async Cancel Safety: AC-Safe This function is safe to call from threads that may be asynchronously cancelled.

Since
release v2.1.0.
Parameters
severity_stringThe severity name to get the enum from.
Returns
The enum integer corresponding to the given severity or -1 if the string is not a valid severity name.

◆ stumpless_get_severity_enum_from_buffer()

STUMPLESS_PUBLIC_FUNCTION enum stumpless_severity stumpless_get_severity_enum_from_buffer ( const char * buffer,
size_t length )

Gets the enum value corresponding to the given severity string in a buffer.

Thread Safety: MT-Safe This function is thread safe.

Async Signal Safety: AS-Safe This function is safe to call from signal handlers.

Async Cancel Safety: AC-Safe This function is safe to call from threads that may be asynchronously cancelled.

Since
release v2.2.0.
Parameters
bufferThe buffer containing the severity name to get the enum from.
lengthThe length of the buffer.
Returns
The enum integer corresponding to the given severity or -1 if the string is not a valid severity name.

◆ stumpless_get_severity_string()

STUMPLESS_PUBLIC_FUNCTION const char * stumpless_get_severity_string ( enum stumpless_severity severity)

Gets the string representation of the given severity.

This is a string literal that should not be modified or freed by the caller.

Thread Safety: MT-Safe This function is thread safe.

Async Signal Safety: AS-Safe This function is safe to call from signal handlers.

Async Cancel Safety: AC-Safe This function is safe to call from threads that may be asynchronously cancelled.

Parameters
severityThe severity to get the string from.
Returns
The string representation of the given severity.