Main Page | Modules | Data Structures | File List | Data Fields

Logging


Defines

#define u_log_err(ecode, facility, ctx,)
 log an error message and die
#define u_log_warning(facility, ctx,)   u_log_write(facility, LOG_WARNING, ctx, __VA_ARGS__)
 log a warning message
#define u_log_info(facility, ctx,)   u_log_write(facility, LOG_INFO, ctx, __VA_ARGS__)
 log an informational message
#define u_log_debug(facility, ctx,)   u_log_write(facility, LOG_DEBUG, ctx, __VA_ARGS__)
 log a debug message
#define die(ecode,)   u_log_err(ecode, facility, 1, __VA_ARGS__)
 same as u_log_err but using the facility global variable
#define die_if(expr)   if(expr) die(EXIT_FAILURE, #expr)
 calls die() if expr is true
#define warning()   u_log_warning(facility, 1, __VA_ARGS__)
 same as u_log_warning but using the facility global variable
#define info()   u_log_info(facility, 0, __VA_ARGS__)
 same as u_log_info but using the facility global variable
#define debug()   u_log_debug(facility, 1, __VA_ARGS__)
 same as u_log_debug but using the facility global variable
#define console()   (fprintf(stderr, __VA_ARGS__) && fprintf(stderr, "\n"))
 write a log message to stderr

Typedefs

typedef int(* u_log_hook_t )(void *arg, int level, const char *str)
 log hook typedef

Functions

int u_log_set_hook (u_log_hook_t hook, void *arg, u_log_hook_t *old, void **parg)
 set a log hook to redirect log messages

Variables

int facility
 per-process facility variable.

Detailed Description

Logging levels
NOTE
All functions that not contain the [facility] parameter reference a variable named "facility" that must be defined somewhere and must be in scope.
Common parameters

Define Documentation

#define u_log_debug facility,
ctx   )     u_log_write(facility, LOG_DEBUG, ctx, __VA_ARGS__)
 

Write a debug log message.

Parameters:
facility facility
ctx set to zero if you don't want context, 1 otherwise
... printf-style variable length arguments list

Definition at line 134 of file log.h.

#define u_log_err ecode,
facility,
ctx   ) 
 

Value:

do {                                                    \
        u_log_write(facility, LOG_ERR, ctx, __VA_ARGS__);   \
        exit(ecode);                                        \
    } while(0)
Write an error log message and die.

Parameters:
ecode exit code
facility facility
ctx set to zero if you don't want context, 1 otherwise
... printf-style variable length arguments list

Definition at line 98 of file log.h.

#define u_log_info facility,
ctx   )     u_log_write(facility, LOG_INFO, ctx, __VA_ARGS__)
 

Write an informational log message.

Parameters:
facility facility
ctx set to zero if you don't want context, 1 otherwise
... printf-style variable length arguments list

Definition at line 123 of file log.h.

#define u_log_warning facility,
ctx   )     u_log_write(facility, LOG_WARNING, ctx, __VA_ARGS__)
 

Write a warning log message.

Parameters:
facility facility
ctx set to zero if you don't want context, 1 otherwise
... printf-style variable length arguments list

Definition at line 112 of file log.h.


Function Documentation

int u_log_set_hook u_log_hook_t  hook,
void *  arg,
u_log_hook_t old,
void **  parg
 

Force the log subsystem to use user-provided function to write log messages.

The provided function will be called for each dbg_, warn_ or info_ calls.

Parameters:
hook function that will be called to write log messages set this param to NULL to set the default syslog-logging
arg an opaque argument that will be passed to the hook function
old [out] will get the previously set hook or NULL if no hook has been set
parg [out] will get the previously set hook argument
Returns:
0 on success, not zero on error

Definition at line 86 of file log.c.


Variable Documentation

int facility
 

all processes that use the libu must define a "facility" variable somewhere to satisfy this external linkage reference.

Such variable will be used as the syslog(3) facility argument.


←Products
© 2005-2006 - KoanLogic S.r.l. - All rights reserved