Logging

Yimmo logging API.

Warning

The log API and format are more tailored to libyimmo development than they are to development of projects which use libyimmo. Tidying this up is on the TODO list.

type ymo_log_level_t

Yimmo log levels.

YMO_LOG_FATAL

An event has occurred which is considered unrecoverable.

YMO_LOG_ERROR

An event has occurred which limits or prevents normal operation for at least one connection.

YMO_LOG_WARNING

An error may occur if no corrective action is taken.

YMO_LOG_NOTICE

An anomlous or noteworthy event has taken place.

YMO_LOG_INFO

General non-error, user information.

YMO_LOG_DEBUG

General non-error, developer information.

YMO_LOG_TRACE

This is a log level intended almost exclusively for yimmo development. It provides fine-grained logging on most of the internal functions, including parsing operations and object creation/destruction.

Definition
typedef enum ymo_log_level {
    /** An event has occurred which is considered unrecoverable. */
    YMO_LOG_FATAL,
    /** An event has occurred which limits or prevents normal
     *  operation for at least one connection. */
    YMO_LOG_ERROR,
    /** An error may occur if no corrective action is taken. */
    YMO_LOG_WARNING,
    YMO_LOG_NOTICE, /* An anomlous or noteworthy event has taken place. */
    YMO_LOG_INFO,   /* General non-error, no-developer information. */
    YMO_LOG_DEBUG,  /* General non-error, developer information. */
    /** This is a log level intended almost exclusively for yimmo development.
     *  It provides fine-grained logging on most of the internal functions,
     *  including parsing operations and object creation/destruction. */
    YMO_LOG_TRACE,
} ymo_log_level_t;
void ymo_log_init(void)

Initialize the logger (atm, just sets the level from the env var, YIMMO_LOG_LEVEL).

void ymo_log(ymo_log_level_t level, const char *fmt, ...);

Log function

Parameters
  • level – the log level of the current message

  • fmt – printf-style format string for subsequent variadic args

void ymo_log_msg(ymo_log_level_t level, const char *msg)

Log function

Parameters
  • level – the log level of the current message

  • msg – puts-style log message

ymo_log_level_t ymo_log_get_level(void)

Get the current log-level.

Returns

the current log level

const char *ymo_log_get_level_name(ymo_log_level_t level)

Get the name for a given log level.

Parameters
  • level – the level whose name we want

Returns

the level name in string form

ymo_log_level_t ymo_log_set_level(ymo_log_level_t level)

Set the current log-level.

Parameters
  • level – the level at which the logger should omit messages

Returns

the current log level

ymo_log_level_t ymo_log_set_level_by_name(const char *level_name)

Set the current log-level by name, e.g. ymo_log_set_level_by_name(“TRACE”)

Parameters
  • level – the level at which the logger should omit messages

Returns

the current log level

Compile time log-level max.

ymo_log_fatal

Compile-time FATAL log function/convenience macro

Definition
#define ymo_log_fatal(...) \
        ymo_log(YMO_LOG_FATAL, __VA_ARGS__)
ymo_log_error

Compile-time ERROR log function/convenience macro

Definition
#define ymo_log_error(...) \
        ymo_log(YMO_LOG_ERROR, __VA_ARGS__)
ymo_log_warning

Compile-time WARNING log function/convenience macro

Definition
#define ymo_log_warning(...) \
        ymo_log(YMO_LOG_WARNING, __VA_ARGS__)
ymo_log_notice

Compile-time NOTICE log function/convenience macro

Definition
#define ymo_log_notice(...) \
        ymo_log(YMO_LOG_NOTICE, __VA_ARGS__)
ymo_log_info

Compile-time INFO log function/convenience macro

Definition
#define ymo_log_info(...) \
        ymo_log(YMO_LOG_INFO, __VA_ARGS__)
ymo_log_debug

Compile-time DEBUG log function/convenience macro

Definition
#define ymo_log_debug(fmt, ...) \
        ymo_log(YMO_LOG_DEBUG, "%s:%i: "fmt, __func__, __LINE__, __VA_ARGS__)
ymo_log_trace

Compile-time TRACE log function/convenience macro

Definition
#define ymo_log_trace(fmt, ...) \
        ymo_log(YMO_LOG_TRACE, "%s:%s:%i: "fmt, YMO_SOURCE, __func__, __LINE__, __VA_ARGS__)