Logging facility

Variables

log_debug, log_trace


By default, debug and tracing are disabled
set log_debug or log_trace to 1 if you want to enable it

LIBEXPORT boolean_t log_debug 
LIBEXPORT boolean_t log_trace 

log_trace_callers


Allows to dump backtraces with messages

boolean_t log_trace_callers 

Constants

Logging severities.

LOG_DEBUG and LOG_TRACE are working only if appropriate variables are set.

#define LOG_CRIT    0
#define LOG_ERROR   1
#define LOG_WARN    2
#define LOG_INFO    3
#define LOG_DEBUG   4
#define LOG_TRACE   5

Functions

log_fini, log_init

public

LIBEXPORT int log_init()
LIBEXPORT void log_fini()

logerror

public


Log error provided by errno

LIBEXPORT int logerror()

logmsg_src

public


Log message to default logging location
No need to add n to format string

ARGUMENTS

RETURN VALUES
number of written symbols or -1 if message was discarded due to severity

LIBEXPORT int logmsg_src(int severity, const char* source, const char* format, ...)

logmsg_src_va

public


Same as logmsg_src(), but accepts varargs

LIBEXPORT int logmsg_src_va(int severity, const char* source, const char* format, va_list args)

logmsg_va, logmsg


Logging macro. Implemented by logmsg_src()

To use it, define LOG_SOURCE before including log.h:

#define LOG_SOURCE
#include <log.h>

#define logmsg(severity, ...)
#define logmsg_va(severity, format, va)