#include <stdarg.h>
#include "project_utilities.h"
Go to the source code of this file.
Defines | |
#define | LOGERR_H 1 |
The standard guard against including the same header twice. | |
#define | LOGERR_THRESHOLD_REPORT LOGERR_DEBUG |
The error severity threshold for reporting errors. | |
#define | LOGERR_THRESHOLD_ABORT LOGERR_ERR |
The error threshold for aborting the application. | |
#define | LOGERR_MAKE_EASY(NICENAME, UGLYCODE) |
Used to generate the entire family of named error handlers. | |
#define | logerr_assert(priority, title, condition) |
Make a prioritized assertion as a special case of an error message. | |
#define | LOGERR_FUNC NULL |
Do not report function names if there's no obvious way to track them. | |
Typedefs | |
typedef void(* | logerr_message_poster_t )(int priority, const char *title, const char *message) |
A generic pointer to function reporting most errors. | |
typedef void(* | logerr_perror_poster_t )(int priority, const char *title, const char *message, const char *syserr) |
A generic pointer to function reporting most system errors. | |
Enumerations | |
enum | logerr_priority { LOGERR_EMERG = 0, LOGERR_ALERT = 1, LOGERR_CRIT = 2, LOGERR_ERR = 3, LOGERR_WARNING = 4, LOGERR_NOTICE = 5, LOGERR_INFO = 6, LOGERR_DEBUG = 7 } |
Error severity codes (an ordered sequence). More... | |
Functions | |
void | logerr_vdispatch (int priority, const char *title, const char *fmt, va_list ap) |
Format the error message and pass it to the currently registered handler. | |
void | logerr_dispatch (int priority, const char *title, const char *fmt,...) |
A wrapper for logerr_vdispatch, taking a variable number of arguments. | |
void | logerr_vperror (int priority, int errnum, const char *title, const char *fmt, va_list ap) |
Format a system error message, passing it to the registered handler. | |
void | logerr_perror (int priority, int errnum, const char *title, const char *fmt,...) |
A wrapper for logerr_vperror, taking a variable number of arguments. | |
void | logerr_set_abort_threshold (int threshold) |
Set the severity threshold for aborting the application. | |
void | logerr_set_messenger (logerr_message_poster_t messenger) |
Register the normal error-reporting callback. | |
void | logerr_set_perror_messenger (logerr_perror_poster_t poster) |
Register the system error-reporting callback. |
The collection of macros providing a friendly front end to a couple of error reporting functions that an application can override with its own callbacks if necessary (based partly on ideas lifted from the error logging for GLib, the core library for GTK+ and GNOME). Errors have a ranked series of severities, and there are no messages reporting errors below a certain severity threshold. For reasons of efficiency, it would be nice if the compiler did not generate code for messages that never appear, but simply having them removed in the preprocessor (using ifdefs, for example) can prevent the compiler finding syntax errors and other bugs that will appear when the error reporting threshold is lowered for debugging. So we go through a few minor contortions to encourage the pre-processor to generate source that will be parsed by the compiler, but which on recent versions of gcc and other such optimizing compilers will not end up in the object code.
Definition in file logerr.h.
|
Value: do { \ if (priority <= LOGERR_THRESHOLD_REPORT) { \ if (!(condition)) \ logerr_dispatch(priority, title, \ "file %s: line %d: assertion (%s) failed", \ __FILE__, __LINE__, (#condition)); \ } \ } while (0);
Definition at line 267 of file logerr.h. Referenced by bresenham_next(), bresenham_next_s(), demolish_bresenham(), dispose_doclist(), make_property(), sad_dispose_doc(), sad_get_doc_property(), sad_put_doc(), and sad_put_doc_property(). |
|
Value: static void \ logerr_##NICENAME (const char * title, const char * fmt, ...) \ { \ va_list ap; \ if (UGLYCODE <= LOGERR_THRESHOLD_REPORT) \ { \ va_start (ap, fmt); \ logerr_vdispatch (UGLYCODE, title, fmt, ap); \ va_end (ap); \ } \ } When varadic macros don't work, we generate error-handling functions with the same easy-to-understand names. |
|
Error severity codes (an ordered sequence).
|
|
A wrapper for logerr_vdispatch, taking a variable number of arguments.
Definition at line 156 of file logerr.c. References logerr_vdispatch(). |
|
A wrapper for logerr_vperror, taking a variable number of arguments.
Definition at line 202 of file logerr.c. References logerr_vperror(). |
|
Set the severity threshold for aborting the application.
Definition at line 216 of file logerr.c. References logerr_lock, and logerr_unlock. |
|
Register the normal error-reporting callback.
Definition at line 228 of file logerr.c. References logerr_lock, and logerr_unlock. |
|
Register the system error-reporting callback.
Definition at line 240 of file logerr.c. References logerr_lock, and logerr_unlock. |
|
Format the error message and pass it to the currently registered handler. We format the error message text in a temporary buffer, invoke whatever error handling function is currently registered as the contents of our private application wide pointer, and abort if the severity threshold is passed.
Definition at line 134 of file logerr.c. References LOGERR_THRESHOLD_ABORT. Referenced by logerr_dispatch(). |
|
Format a system error message, passing it to the registered handler.
We format the application error message text in a temporary buffer, get the explanation of a system error number from the
Definition at line 180 of file logerr.c. References LOGERR_THRESHOLD_ABORT. Referenced by logerr_perror(). |