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