/[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 376 by johnpye, Fri Mar 10 09:14:29 2006 UTC revision 377 by johnpye, Wed Mar 15 11:27:22 2006 UTC
# Line 48  Line 48 
48  #define PUTC fputc_error_reporter  #define PUTC fputc_error_reporter
49  #define FFLUSH fflush_error_reporter  #define FFLUSH fflush_error_reporter
50    
51    /*
52        By default, don't use coloured output on any terminals. We will reintroduce
53        this later, hopefully. It should be done using CURSES, instead of directly
54        using xterm codes. But that brings its own problems on MinGW and Windows...
55    */
56    
57    #ifdef USE_XTERM_COLOR_CODES
58    /** XTERM colour codes used to distinguish between errors of different types.
59    
60        @TODO some runtime testing to determine if these should be used or not
61        depending on TERM env var.
62    */
63    #  define ERR_RED "\033[31;1m"
64    #  define ERR_GRN "\033[32;2m"
65    #  define ERR_BLU "\033[34;1m"
66    #  define ERR_BRN "\033[33;1m"
67    #  define ERR_NORM "\033[0m"
68    #  define ERR_BOLD "\033[1m"
69    #else
70    #  define ERR_RED ""
71    #  define ERR_GRN ""
72    #  define ERR_BLU ""
73    #  define ERR_BRN ""
74    #  define ERR_NORM ""
75    #  define ERR_BOLD ""
76    #endif
77  /**  /**
78      Variadic macros to allow nice succint logging and error reporting      Variadic macros to allow nice succint logging and error reporting
79      calls from C dialects that support them (GCC, C99 and others)      calls from C dialects that support them (GCC, C99 and others)
# Line 59  Line 85 
85  # define ERROR_REPORTER_DEBUG(args...) error_reporter(ASC_PROG_NOTE, __FILE__, __LINE__, __func__, ##args)  # define ERROR_REPORTER_DEBUG(args...) error_reporter(ASC_PROG_NOTE, __FILE__, __LINE__, __func__, ##args)
86  # define ERROR_REPORTER_HERE(SEV,args...) error_reporter(SEV,__FILE__, __LINE__, __func__, ##args)  # define ERROR_REPORTER_HERE(SEV,args...) error_reporter(SEV,__FILE__, __LINE__, __func__, ##args)
87  # define ERROR_REPORTER_NOLINE(SEV,args...) error_reporter(SEV, NULL, 0, NULL, ##args)  # define ERROR_REPORTER_NOLINE(SEV,args...) error_reporter(SEV, NULL, 0, NULL, ##args)
88  # define CONSOLE_DEBUG(args...) (fprintf(stderr,"\33[1m%s:%d (%s): ", __FILE__,__LINE__,__func__) + \  # define CONSOLE_DEBUG(args...) (fprintf(stderr, ERR_BOLD "%s:%d (%s): ", __FILE__,__LINE__,__func__) + \
89                                   fprintf(stderr, ##args) + \                                   fprintf(stderr, ##args) + \
90                                   fprintf(stderr, "\33[0m\n"))                                   fprintf(stderr, ERR_NORM "\n"))
91    
92  #elif defined(HAVE_C99)  #elif defined(HAVE_C99)
93  # define ERROR_REPORTER_DEBUG(...) error_reporter(ASC_PROG_NOTE,__FILE__,__LINE__,__func__,## __VA_ARGS__)  # define ERROR_REPORTER_DEBUG(...) error_reporter(ASC_PROG_NOTE,__FILE__,__LINE__,__func__,## __VA_ARGS__)
94  # define ERROR_REPORTER_HERE(SEV,...) error_reporter(SEV,__FILE__,__LINE__,__func__, ## __VA_ARGS__)  # define ERROR_REPORTER_HERE(SEV,...) error_reporter(SEV,__FILE__,__LINE__,__func__, ## __VA_ARGS__)
95  # define ERROR_REPORTER_NOLINE(SEV,...) error_reporter(SEV,NULL,0,NULL, ## __VA_ARGS__)  # define ERROR_REPORTER_NOLINE(SEV,...) error_reporter(SEV,NULL,0,NULL, ## __VA_ARGS__)
96  # define CONSOLE_DEBUG(...) (fprintf(stderr,"\33[1m%s:%d (%s): ", __FILE__,__LINE__,__func__) + \  # define CONSOLE_DEBUG(...) (fprintf(stderr, ERR_BOLD "%s:%d (%s): ", __FILE__,__LINE__,__func__) + \
97                               fprintf(stderr, ##__VA_ARGS__) + \                               fprintf(stderr, ##__VA_ARGS__) + \
98                               fprintf(stderr, "\33[0m\n"))                               fprintf(stderr, ERR_NORM "\n"))
99    
100  #else  #else
101  # define ERROR_REPORTER_DEBUG error_reporter_note_no_line  # define ERROR_REPORTER_DEBUG error_reporter_note_no_line

Legend:
Removed from v.376  
changed lines
  Added in v.377

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