Message Logging

Table of Contents

Synopsis
Description
Details

Message Logging - support for logging messages

Synopsis

enum    EDNetLogLevel;
typedef EDNetLogFunc;

void ednet_log             (EDNetLogLevel level,
                            void         *object,
                            const char   *fmt,
                            ...);
void ednet_log_set_handler (EDNetLogFunc  func,
                            void         *data);
void ednet_log_set_level   (EDNetLogLevel level);

Description

These functions provide support for logging error messages or messages used for debugging.

There are several built-in levels of messages, defined in EDNetLogLevel.

Details

EDNetLogLevel

typedef enum
{
  EDNET_LOG_DEBUG,
  EDNET_LOG_INFO,
  EDNET_LOG_WARNING,
  EDNET_LOG_ERROR
} EDNetLogLevel;

Log message level.

EDNET_LOG_DEBUG :

debug messages (lowest)

EDNET_LOG_INFO :

informative message

EDNET_LOG_WARNING :

non-critical warning messages

EDNET_LOG_ERROR :

critical error messages (highest)

EDNetLogFunc

typedef void (*EDNetLogFunc) (const char *buf, void *data);

Specifies the type of function which is called when log messages are printed.

ednet_log ()

void ednet_log             (EDNetLogLevel level,
                            void         *object,
                            const char   *fmt,
                            ...);

Prints log messages with specified level. If there is no handler registered via ednet_log_set_handler(), messages will be printed on standard error terminal output (stderr). Log messages whose level is lower than one specified with ednet_log_set_level() will be ignored.

If log message level is EDNET_LOG_ERROR, program will be stopped by calling abort().

level :

log message level

object :

log message sender, NULL is acceptable.

fmt :

printf-style message format

ednet_log_set_handler ()

void ednet_log_set_handler (EDNetLogFunc  func,
                            void         *data);

Registers log message handler function which called when log messages are printed by ednet_log(). User data is passed as the second parameter on calling handler function.

func :

log message handler

data :

user data

ednet_log_set_level ()

void ednet_log_set_level   (EDNetLogLevel level);

Determines the log message level, which log messages whose level is lower than will not be printed.

Default log message level is EDNET_LOG_INFO.

level :

log message level