DTNMA Reference Tools v2.0.0 - 7.g88e232c
Delay-Tolerant Networking Management Architecture (DTNMA) Tool Suite
Loading...
Searching...
No Matches
logging.h File Reference

Abstract interface for event logging. More...

#include <syslog.h>
#include <stdbool.h>
+ Include dependency graph for logging.h:

Macros

#define CACE_LOG_CRIT(...)   cace_log(LOG_CRIT, __FILE__, __LINE__, __func__, __VA_ARGS__)
 Perform LOG_CRIT level logging with auto-filled parameters.
 
#define CACE_LOG_ERR(...)   cace_log(LOG_ERR, __FILE__, __LINE__, __func__, __VA_ARGS__)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
#define CACE_LOG_WARNING(...)   cace_log(LOG_WARNING, __FILE__, __LINE__, __func__, __VA_ARGS__)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
#define CACE_LOG_INFO(...)   cace_log(LOG_INFO, __FILE__, __LINE__, __func__, __VA_ARGS__)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
#define CACE_LOG_DEBUG(...)   cace_log(LOG_DEBUG, __FILE__, __LINE__, __func__, __VA_ARGS__)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 

Functions

void cace_openlog (void)
 Opens the event log.
 
void cace_closelog (void)
 Closes the event log.
 
int cace_log_get_severity (int *severity, const char *name)
 Interpret a text name as a severity level.
 
void cace_log_set_least_severity (int severity)
 Set the least severity enabled for logging.
 
bool cace_log_is_enabled_for (int severity)
 Determine if a particular severity is being logged.
 
void cace_log (int severity, const char *filename, int lineno, const char *funcname, const char *format,...)
 Log an event.
 

Detailed Description

Abstract interface for event logging.

Macro Definition Documentation

◆ CACE_LOG_CRIT

#define CACE_LOG_CRIT (   ...)    cace_log(LOG_CRIT, __FILE__, __LINE__, __func__, __VA_ARGS__)

Perform LOG_CRIT level logging with auto-filled parameters.

The arguments to this macro are passed to cace_log() as the format and its parameter values.

Function Documentation

◆ cace_closelog()

void cace_closelog ( void  )

Closes the event log.

This is a mimic to POSIX closelog()

See also
cace_openlog

References cace_log_event_t::message, and cace_log_event_t::severity.

◆ cace_log()

void cace_log ( int  severity,
const char *  filename,
int  lineno,
const char *  funcname,
const char *  format,
  ... 
)

Log an event.

Parameters
severityThe severity from a subset of the POSIX syslog values.
[in]filenameThe originating file name, which may include directory parts.
[in]linenoThe originating file line number.
[in]funcnameThe originating function name.
[in]formatThe log message format string.
...Values for the format string.

References cace_log_is_enabled_for(), cace_log_event_t::context, cace_log_event_t::message, and cace_log_event_t::severity.

◆ cace_log_get_severity()

int cace_log_get_severity ( int *  severity,
const char *  name 
)

Interpret a text name as a severity level.

Parameters
[out]severityThe associated severity level.
[in]nameThe text name, which is case insensitive.
Returns
Zero if successful.

References CHKERR1.

◆ cace_log_is_enabled_for()

bool cace_log_is_enabled_for ( int  severity)

Determine if a particular severity is being logged.

This function is multi-thread safe.

Parameters
severityThe severity from a subset of the POSIX syslog values.
Returns
True if the severity level will be logged.
See also
cace_log_set_least_severity

Referenced by cace_amp_msg_decode(), cace_amp_msg_encode(), and cace_log().

◆ cace_log_set_least_severity()

void cace_log_set_least_severity ( int  severity)

Set the least severity enabled for logging.

Other events will be dropped by the logging facility. This function is multi-thread safe.

Parameters
severityThe severity from a subset of the POSIX syslog values.
See also
cace_log_is_enabled_for

◆ cace_openlog()

void cace_openlog ( void  )

Opens the event log.

Note
This should be called once per process, not thread or library instance. At the end of the process there should be a call to cace_closelog()

This is a mimic to POSIX openlog()

References cace_log_event_t::message, and cace_log_event_t::severity.