Last change
on this file was
19276,
checked in by westram, 2 years ago
|
- add class MessageSpamFilter
- helps suppressing too many messages sent via GB_warning()
- forwards suppressed warnings as message (=into logfile via console).
- warns about suppressed messages
|
File size:
1.6 KB
|
Line | |
---|
1 | // ========================================================= // |
---|
2 | // // |
---|
3 | // File : arb_msg_nospam.h // |
---|
4 | // Purpose : provide suppression for repeated warnings // |
---|
5 | // // |
---|
6 | // Coded by Ralf Westram (coder@reallysoft.de) in Oct 22 // |
---|
7 | // http://www.arb-home.de/ // |
---|
8 | // // |
---|
9 | // ========================================================= // |
---|
10 | |
---|
11 | #ifndef ARB_MSG_NOSPAM_H |
---|
12 | #define ARB_MSG_NOSPAM_H |
---|
13 | |
---|
14 | #ifndef ARBTOOLS_H |
---|
15 | #include <arbtools.h> |
---|
16 | #endif |
---|
17 | #ifndef _GLIBCXX_STRING |
---|
18 | #include <string> |
---|
19 | #endif |
---|
20 | |
---|
21 | class MessageSpamFilter : virtual Noncopyable { |
---|
22 | // When instantiated -> suppresses messages sent via GB_warning(), |
---|
23 | // if more than 'acceptedMessages' get shown while instance exists. |
---|
24 | // |
---|
25 | // * should be installed by all callers that might cause dozens or hundreds of warnings! |
---|
26 | // * warnings will still be logged into logfile via console. |
---|
27 | |
---|
28 | MessageSpamFilter *previous_spamfilter; |
---|
29 | std::string what_is_filtered; |
---|
30 | |
---|
31 | // message counters: |
---|
32 | int shown; |
---|
33 | int suppressed; |
---|
34 | int accepted; |
---|
35 | |
---|
36 | static MessageSpamFilter *current_spamfilter; |
---|
37 | |
---|
38 | void filter_warning(const char *message); |
---|
39 | bool is_spam(); |
---|
40 | |
---|
41 | public: |
---|
42 | MessageSpamFilter(std::string what_is_filtered_, int acceptedMessages = 5); |
---|
43 | ~MessageSpamFilter(); |
---|
44 | |
---|
45 | // same as arb_handlers inferface: |
---|
46 | static void show_warning(const char *message); |
---|
47 | }; |
---|
48 | |
---|
49 | |
---|
50 | #else |
---|
51 | #error arb_msg_nospam.h included twice |
---|
52 | #endif // ARB_MSG_NOSPAM_H |
---|
53 | |
---|
Note: See
TracBrowser
for help on using the repository browser.