Debug/error logging

Functions for debugging and error messages. More...

Typedefs

typedef void(*) GGZDebugHandlerFunc (int priority, const char *msg)
 A callback function to handle debugging output.

Enumerations

enum  GGZCheckType { GGZ_CHECK_NONE = 0x00, GGZ_CHECK_MEM = 0x01 }
 What memory checks should we do? More...

Functions

void ggz_debug_init (const char **types, const char *file)
 Initialize and configure debugging for the program.
GGZDebugHandlerFunc ggz_debug_set_func (GGZDebugHandlerFunc func)
 Set the debug handler function.
void ggz_debug_enable (const char *type)
 Enable a specific type of debugging.
void ggz_debug_disable (const char *type)
 Disable a specific type of debugging.
void ggz_debug (const char *type, const char *fmt,...) ggz__attribute((format(printf
 Log a debugging message.
void void ggz_log (const char *type, const char *fmt,...) ggz__attribute((format(printf
 Log a notice message.
void void void ggz_error_sys (const char *fmt,...) ggz__attribute((format(printf
 Log a syscall error.
void void void void ggz_error_sys_exit (const char *fmt,...) ggz__attribute((format(printf
 Log a fatal syscall error.
void void void void ggz__attribute ((noreturn))
void ggz_error_msg (const char *fmt,...) ggz__attribute((format(printf
 Log an error message.
void void ggz_error_msg_exit (const char *fmt,...) ggz__attribute((format(printf
 Log a fatal error message.
void ggz_debug_cleanup (GGZCheckType check)
 Cleans up debugging state and prepares for exit.

Detailed Description

Functions for debugging and error messages.


Typedef Documentation

typedef void(*) GGZDebugHandlerFunc(int priority, const char *msg)

A callback function to handle debugging output.

A function of this type can be registered as a callback handler to handle debugging output, rather than having the output go to stderr or to a file. If this is done, each line of output will be sent directly to this function (no trailing newline will be appended).

See also:
ggz_debug_set_func
Parameters:
priority The priority of the log, i.e. LOG_DEBUG; see syslog()
msg The debugging output message
Note:
If your program is threaded, this function must be threadsafe.


Enumeration Type Documentation

enum GGZCheckType

What memory checks should we do?

See also:
ggz_debug_cleanup
Enumerator:
GGZ_CHECK_NONE  No checks.
GGZ_CHECK_MEM  Memory (leak) checks.


Function Documentation

void ggz_debug_init ( const char **  types,
const char *  file 
)

Initialize and configure debugging for the program.

This should be called early in the program to set up the debugging routines.

Parameters:
types A null-terminated list of arbitrary string debugging "types"
file A file to write debugging output to, or NULL for none
See also:
ggz_debug

GGZDebugHandlerFunc ggz_debug_set_func ( GGZDebugHandlerFunc  func  ) 

Set the debug handler function.

Call this function to register a debug handler function. NULL can be passed to disable the debug handler. If set, the debug handler function will be called to handle debugging output, overriding any file that had previously been specified.

Parameters:
func The new debug handler function
Returns:
The previous debug handler function
Note:
This function is not threadsafe (re-entrant).

void ggz_debug_enable ( const char *  type  ) 

Enable a specific type of debugging.

Any ggz_debug() calls that use that type will then be logged.

Parameters:
type The "type" of debugging to enable
See also:
ggz_debug

void ggz_debug_disable ( const char *  type  ) 

Disable a specific type of debugging.

Any ggz_debug() calls that use the given type of debugging will then not be logged.

Parameters:
type The "type" of debugging to disable
See also:
ggz_debug

void ggz_debug ( const char *  type,
const char *  fmt,
  ... 
)

Log a debugging message.

This function takes a debugging "type" as well as a printf-style list of arguments. It assembles the debugging message (printf-style) and logs it if the given type of debugging is enabled.

Parameters:
type The "type" of debugging (similar to a loglevel)
fmt A printf-style format string
See also:
ggz_debug_enable, ggz_debug_disable

void void ggz_log ( const char *  type,
const char *  fmt,
  ... 
)

Log a notice message.

This function is nearly identical to ggz_debug(), except that if the debugging output ends up passed to the debug handler function, the priority will be LOG_NOTICE instead of LOG_DEBUG. This is only of interest to a few programs.

Parameters:
type The "type" of debugging (similar to a loglevel)
fmt A printf-style format string
See also:
ggz_debug, ggz_debug_set_func

void void void ggz_error_sys ( const char *  fmt,
  ... 
)

Log a syscall error.

This logs an error message in a similar manner to ggz_debug()'s debug logging. However, the logging is done regardless of whether debugging is enabled or what debugging types are set. errno and strerror are also used to create a more useful message.

Parameters:
fmt A printf-style format string
See also:
ggz_debug

void void void void ggz_error_sys_exit ( const char *  fmt,
  ... 
)

Log a fatal syscall error.

This logs an error message just like ggz_error_sys(), and also exits the program.

Parameters:
fmt A printf-style format string

void ggz_error_msg ( const char *  fmt,
  ... 
)

Log an error message.

This logs an error message in a similar manner to ggz_debug()'s debug logging. However, the logging is done regardless of whether debugging is enabled or what debugging types are set.

Parameters:
fmt A printf-style format string
Note:
This is equivalent to ggz_debug(NULL, ...) with debugging enabled.

void void ggz_error_msg_exit ( const char *  fmt,
  ... 
)

Log a fatal error message.

This logs an error message just like ggz_error_msg(), and also exits the program.

Parameters:
fmt A printf-style format string

void ggz_debug_cleanup ( GGZCheckType  check  ) 

Cleans up debugging state and prepares for exit.

This function should be called right before the program exits. It cleans up all of the debugging state data, including writing out the memory check data (if enabled) and closing the debugging file (if enabled).

Parameters:
check A mask of things to check


Generated on Fri Nov 30 14:58:03 2007 for LibGGZ by  doxygen 1.5.1