00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef SC_REPORT_HANDLER_H
00029 #define SC_REPORT_HANDLER_H
00030
00031 namespace sc_core {
00032
00033
00034
00035
00036
00037
00038
00039 struct sc_msg_def
00040 {
00041 const char* msg_type;
00042 sc_actions actions;
00043 sc_actions sev_actions[SC_MAX_SEVERITY];
00044 unsigned limit;
00045 unsigned sev_limit[SC_MAX_SEVERITY];
00046 unsigned limit_mask;
00047 unsigned call_count;
00048 unsigned sev_call_count[SC_MAX_SEVERITY];
00049 char* msg_type_data;
00050
00051 int id;
00052 };
00053
00054 typedef void (* sc_report_handler_proc)(const sc_report&, const sc_actions &);
00055 class sc_report;
00056 extern bool sc_report_close_default_log();
00057 class sc_report_handler
00058 {
00059 public:
00060 static void report(sc_severity,
00061 const char* msg_type,
00062 const char* msg,
00063 const char* file,
00064 int line);
00065
00066 static void report( sc_severity,
00067 const char* msg_type,
00068 const char* msg,
00069 int verbosity,
00070 const char* file,
00071 int line );
00072
00073 static sc_actions set_actions(sc_severity,
00074 sc_actions = SC_UNSPECIFIED);
00075
00076 static sc_actions set_actions(const char * msg_type,
00077 sc_actions = SC_UNSPECIFIED);
00078
00079 static sc_actions set_actions(const char * msg_type,
00080 sc_severity,
00081 sc_actions = SC_UNSPECIFIED);
00082
00083 static int stop_after(sc_severity, int limit = -1);
00084 static int stop_after(const char* msg_type, int limit = -1);
00085 static int stop_after(const char* msg_type, sc_severity, int limit = -1);
00086
00087 static sc_actions suppress(sc_actions);
00088 static sc_actions suppress();
00089 static sc_actions force(sc_actions);
00090 static sc_actions force();
00091
00092 static int get_count(sc_severity severity_);
00093 static int get_count(const char* msg_type_);
00094 static int get_count(const char* msg_type_, sc_severity severity_);
00095
00096 static int get_verbosity_level();
00097 static int set_verbosity_level( int level );
00098
00099
00100 static void initialize();
00101 static void release();
00102
00103 static sc_report_handler_proc set_handler(sc_report_handler_proc);
00104 static sc_report_handler_proc get_handler();
00105
00106 static void default_handler(const sc_report&, const sc_actions&);
00107
00108 static sc_actions get_new_action_id();
00109
00110 static sc_report* get_cached_report();
00111 static void clear_cached_report();
00112
00113
00114
00115
00116 static bool set_log_file_name(const char* filename);
00117 static const char* get_log_file_name();
00118
00119 public:
00120
00121 struct msg_def_items
00122 {
00123 sc_msg_def* md;
00124 int count;
00125 bool allocated;
00126 msg_def_items* next;
00127 };
00128
00129 static void add_static_msg_types(msg_def_items *);
00130 static sc_msg_def* add_msg_type(const char * msg_type);
00131
00132 protected:
00133
00134 static void cache_report(const sc_report&);
00135 static sc_actions execute(sc_msg_def*, sc_severity);
00136
00137 static sc_actions suppress_mask;
00138 static sc_actions force_mask;
00139 static sc_actions sev_actions[SC_MAX_SEVERITY];
00140 static unsigned sev_limit[SC_MAX_SEVERITY];
00141 static unsigned sev_call_count[SC_MAX_SEVERITY];
00142 static sc_report* last_global_report;
00143 static sc_actions available_actions;
00144 static char* log_file_name;
00145 static int verbosity_level;
00146
00147 static msg_def_items* messages;
00148 static msg_def_items msg_terminator;
00149
00150 static sc_report_handler_proc handler;
00151
00152 static sc_msg_def* mdlookup(const char* msg_type);
00153
00154 private:
00155
00156 friend class sc_report;
00157 static sc_msg_def* mdlookup(int id);
00158
00159 public:
00160
00161 static void report(sc_severity,
00162 int id,
00163 const char* add_msg,
00164 const char* file,
00165 int line);
00166
00167 };
00168
00169 }
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193 #endif
00194
00195