#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "logerr.h"
Go to the source code of this file.
Defines | |
#define | logerr_lock |
Use genuine a dummy lock operation in a single-threaded environment. | |
#define | logerr_unlock |
Use genuine a dummy unlock operation in a single-threaded environment. | |
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. |
In the logerr.h we define a collection of error reporting macros that are supposed to be flexible, so we can in principle define our own error handling functions and to do things like pop up dialog boxes within a GUI, or add to the system error logs. The application as a whole shares two private pointers to error reporting functions that can either be set to defaults (which simply print to standard error), or overridden by arbitrary callbacks. Errors beyond a redefinable severity threshold abort the entire application (the codes are arranged in decreasing order of severity, so these will be low numbers than the codes for which we report an error without aborting). The functions that register callbacks and change the severity threshold use a single mutex for access control in multithreaded applications, but this is probably overkill since the updating operations are pretty much atomic in any case.
Definition in file logerr.c.
|
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(). |