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