/[ascend]/trunk/base/generic/utilities/error.h
ViewVC logotype

Diff of /trunk/base/generic/utilities/error.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 221 by johnpye, Tue Jan 17 05:49:40 2006 UTC revision 222 by johnpye, Fri Jan 27 04:23:20 2006 UTC
# Line 56  Line 56 
56      but without the file/function/line number.      but without the file/function/line number.
57  */  */
58  #if defined(__GNUC__) && !defined(__STRICT_ANSI__)  #if defined(__GNUC__) && !defined(__STRICT_ANSI__)
59  # define ERROR_REPORTER_DEBUG(MSG,args...) error_reporter(ASC_PROG_NOTE,__FILE__,__LINE__,"%s: " MSG, __func__, ##args)  # define ERROR_REPORTER_DEBUG(args...) error_reporter(ASC_PROG_NOTE, __FILE__, __LINE__, __func__, ##args)
60  # define ERROR_REPORTER_HERE(SEV,MSG,args...) error_reporter(SEV,__FILE__,__LINE__,"%s: " MSG, __func__, ##args)  # define ERROR_REPORTER_HERE(SEV,args...) error_reporter(SEV,__FILE__, __LINE__, __func__, ##args)
61  # define ERROR_REPORTER_NOLINE(SEV,MSG,args...) error_reporter(SEV,NULL,0,MSG, ##args)  # define ERROR_REPORTER_NOLINE(SEV,args...) error_reporter(SEV, NULL, 0, NULL, ##args)
62  # define CONSOLE_DEBUG(MSG,args...) fprintf(stderr,"\33[1m%s:%d (%s): " MSG "\33[0m\n",__FILE__,__LINE__,__func__, ##args)  # define CONSOLE_DEBUG(args...) (fprintf(stderr,"\33[1m%s:%d (%s): ", __FILE__,__LINE__,__func__) + \
63                                     fprintf(stderr, ##args) + \
64                                     fprintf(stderr, "\33[0m\n"))
65    
66  #elif defined(HAVE_C99)  #elif defined(HAVE_C99)
67  # define ERROR_REPORTER_DEBUG(MSG,...) error_reporter(ASC_PROG_NOTE,__FILE__,__LINE__,"%s: " MSG,__func__,## __VA_ARGS__)  # define ERROR_REPORTER_DEBUG(...) error_reporter(ASC_PROG_NOTE,__FILE__,__LINE__,__func__,## __VA_ARGS__)
68  # define ERROR_REPORTER_HERE(SEV,MSG,...) error_reporter(SEV,__FILE__,__LINE__,"%s: " MSG, __func__, ## __VA_ARGS__)  # define ERROR_REPORTER_HERE(SEV,...) error_reporter(SEV,__FILE__,__LINE__,__func__, ## __VA_ARGS__)
69  # define ERROR_REPORTER_NOLINE(SEV,MSG,...) error_reporter(SEV,NULL,0,MSG, ## __VA_ARGS__)  # define ERROR_REPORTER_NOLINE(SEV,...) error_reporter(SEV,NULL,0,NULL, ## __VA_ARGS__)
70  # define CONSOLE_DEBUG(MSG,...) fprintf(stderr,"\33[1m%s:%d (%s): " MSG "\33[0m\n",__FILE__,__LINE__,__func__, ## __VA_ARGS__)  # define CONSOLE_DEBUG(...) (fprintf(stderr,"\33[1m%s:%d (%s): ", __FILE__,__LINE__,__func__) + \
71                                 fprintf(stderr, ##__VA_ARGS__) + \
72                                 fprintf(stderr, "\33[0m\n"))
73    
74  #else  #else
75  # define ERROR_REPORTER_DEBUG error_reporter_note_no_line  # define ERROR_REPORTER_DEBUG error_reporter_note_no_line
# Line 78  int error_reporter_noline(const error_se Line 82  int error_reporter_noline(const error_se
82  int console_debug(const char *fmt,...);  int console_debug(const char *fmt,...);
83  #endif  #endif
84    
85    #define ERROR_REPORTER_START_NOLINE(SEV) error_reporter_start(SEV,NULL,0,NULL);
86    #define ERROR_REPORTER_START_HERE(SEV) error_reporter_start(SEV,__FILE__,__LINE__,__func__);
87    
88  #define ERROR_REPORTER_STAT(sev,stat,msg) \  #define ERROR_REPORTER_STAT(sev,stat,msg) \
89      error_reporter(sev,Asc_ModuleFileName(stat->mod),stat->linenum,msg)      error_reporter(sev,Asc_ModuleFileName(stat->mod),stat->linenum,NULL,msg)
90    
91  /**  /**
92      Error severity codes. This will be used to visually      Error severity codes. This will be used to visually
# Line 107  typedef struct{ Line 114  typedef struct{
114      error_severity_t sev;      error_severity_t sev;
115      const char *filename;      const char *filename;
116      int line;      int line;
117        const char *func;
118      char msg[ERROR_REPORTER_MAX_MSG];      char msg[ERROR_REPORTER_MAX_MSG];
119  } error_reporter_meta_t;  } error_reporter_meta_t;
120    
# Line 133  int fflush_error_reporter(FILE *file); Line 141  int fflush_error_reporter(FILE *file);
141      Start a cached error report. This means that multiple frprintf_error_reporter calls will      Start a cached error report. This means that multiple frprintf_error_reporter calls will
142      be stored in a global string until an error_reporter_end_flush is encountered.      be stored in a global string until an error_reporter_end_flush is encountered.
143  */  */
144  int error_reporter_start(const error_severity_t sev, const char *filename, const int line);  int error_reporter_start(const error_severity_t sev, const char *filename, const int line, const char *func);
145    
146  /**  /**
147      Output the contents of the checked global string as an error report      Output the contents of the checked global string as an error report
# Line 145  int error_reporter_end_flush(); Line 153  int error_reporter_end_flush();
153      callback function declarations.      callback function declarations.
154  */  */
155  #define ERROR_REPORTER_CALLBACK_ARGS \  #define ERROR_REPORTER_CALLBACK_ARGS \
156     const error_severity_t sev \      const error_severity_t sev \
157      , const char *filename, const int line \    , const char *filename \
158      , const char *fmt, const va_list args    , const int line \
159      , const char *funcname \
160      , const char *fmt \
161      , const va_list args
162    
163  /*  /*
164      In you have functions which pass-through callback parameters,      In you have functions which pass-through callback parameters,
# Line 155  int error_reporter_end_flush(); Line 166  int error_reporter_end_flush();
166      you won't have to go hunting and change stuff.      you won't have to go hunting and change stuff.
167  */  */
168  #define ERROR_REPORTER_CALLBACK_VARS \  #define ERROR_REPORTER_CALLBACK_VARS \
169      sev, filename, line, fmt, args      sev, filename, line, func, fmt, args
170    
171  /*  /*
172      Define the type of the function pointer to be used for all      Define the type of the function pointer to be used for all
# Line 174  typedef int (*error_reporter_callback_t) Line 185  typedef int (*error_reporter_callback_t)
185      @return follows the style of fprintf      @return follows the style of fprintf
186  */  */
187  int error_reporter(  int error_reporter(
188          const error_severity_t sev        const error_severity_t sev
189          , const char *errfile, const int errline      , const char *errfile
190          , const char *fmt, ...      , const int errline
191        , const char *errfunc
192        , const char *fmt
193        , ...
194  );  );
195    
196  /**  /**

Legend:
Removed from v.221  
changed lines
  Added in v.222

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22