Main Page | Data Structures | Directories | File List | Data Fields | Globals

logerr.c File Reference

Support for error reporting macros. More...

#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.


Detailed Description

Support for error reporting macros.

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.

Author:
University of Arizona Digital Image Analysis Lab
Date:
1999, 2004
Version:
Id
logerr.c,v 1.1 2005/03/22 20:27:45 mmunro Exp

Definition in file logerr.c.


Function Documentation

void logerr_dispatch int  priority,
const char *  title,
const char *  fmt,
  ...
 

A wrapper for logerr_vdispatch, taking a variable number of arguments.

Parameters:
[in] priority the severity for this error.
[in] title where in the application the error originated.
[in] fmt the format string for the remaining arguments.
[in] ... the remaining arguments for generating the message.

Definition at line 156 of file logerr.c.

References logerr_vdispatch().

void logerr_perror int  priority,
int  errnum,
const char *  title,
const char *  fmt,
  ...
 

A wrapper for logerr_vperror, taking a variable number of arguments.

Parameters:
[in] priority the severity for this error.
[in] errnum the system error number.
[in] title where in the application the error originated.
[in] fmt the format string for the remaining arguments.
[in] ... the remaining arguments for generating the message.

Definition at line 202 of file logerr.c.

References logerr_vperror().

void logerr_set_abort_threshold int  threshold  ) 
 

Set the severity threshold for aborting the application.

Parameters:
[in] threshold the new threshold value.

Definition at line 216 of file logerr.c.

References logerr_lock, and logerr_unlock.

void logerr_set_messenger logerr_message_poster_t  messenger  ) 
 

Register the normal error-reporting callback.

Parameters:
[in] messenger the new error-reporting function.

Definition at line 228 of file logerr.c.

References logerr_lock, and logerr_unlock.

void logerr_set_perror_messenger logerr_perror_poster_t  poster  ) 
 

Register the system error-reporting callback.

Parameters:
[in] poster the new system error-reporting function.

Definition at line 240 of file logerr.c.

References logerr_lock, and logerr_unlock.

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.

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.

Parameters:
[in] priority the severity for this error.
[in] title where in the application the error originated.
[in] fmt the format string for the remaining arguments.
[in] ap the remaining arguments for generating the message.

Definition at line 134 of file logerr.c.

References LOGERR_THRESHOLD_ABORT.

Referenced by logerr_dispatch().

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.

We format the application error message text in a temporary buffer, get the explanation of a system error number from the strerror system function, and invoke whatever error system handling function is currently registered as the contents of our private application-wide pointer, aborting if the severity threshold is passed.

Parameters:
[in] priority the severity for this error.
[in] errnum the system error number.
[in] title where in the application the error originated.
[in] fmt the format string for the remaining arguments.
[in] ap the remaining arguments for generating the message.

Definition at line 180 of file logerr.c.

References LOGERR_THRESHOLD_ABORT.

Referenced by logerr_perror().


Generated on Fri Jul 8 14:55:01 2005 for tclSadie by  doxygen 1.4.2