1 /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
2 
3 #ifndef LOG_DEFAULT_FILTER_H
4 #define LOG_DEFAULT_FILTER_H
5 
6 /**
7  * A simple filter implementation for the ILog.h logging API.
8  * It routes passing logging messages to the backend, and allows to set and get,
9  * what is logged and what not.
10  */
11 
12 
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 /**
19  * @name logging_filter_defaultFilter_control
20  * @{
21  */
22 
23 
24 
25 /**
26  * Sets the minimum level to log for all sections, including the default one.
27  *
28  * The compile-time min-level (_LOG_LEVEL_MIN) takes precedence of this one.
29  * This one takes precedence over the section specific one
30  * (log_filter_section_setMinLevel).
31  * You may set a more restrictive min-level then a preceding instance, but
32  * setting a less restrictive one has no effect.
33  *
34  * @see #log_filter_global_getMinLevel
35  * @see #log_filter_section_setMinLevel
36  */
37 void log_filter_global_setMinLevel(int level);
38 
39 /**
40  * Returns the minimum level to log.
41  * @see #log_filter_global_setMinLevel
42  * @see #log_filter_section_getMinLevel
43  */
44 int log_filter_global_getMinLevel();
45 
46 
47 
48 /**
49  * Sets whether log messages for a certain section are logged or not.
50  *
51  * The compile-time min-level (_LOG_LEVEL_MIN) takes precedence of this one.
52  * The global run-time min-level (log_filter_global_setMinLevel) takes
53  * precedence over this one.
54  * You may set a more restrictive min-level then a preceding instance, but
55  * setting a less restrictive one has no effect.
56  *
57  * On release builds, the initial default section (LOG_SECTION_DEFAULT)
58  * min-level is L_INFO, and L_WARNING for non-default sections.
59  * On debug builds, all sections initial min-level is set to L_DEBUG.
60  *
61  * CAUTION: you may only use strings defined at compile-time.
62  * @see #log_filter_section_getMinLevel
63  */
64 void log_filter_section_setMinLevel(const char* section, int level);
65 
66 /**
67  * Returns the minimum level to log for a certain section.
68  * All sections are enabled by default.
69  *
70  * CAUTION: you may only use strings defined at compile-time.
71  * @see #log_filter_section_setMinLevel
72  */
73 int log_filter_section_getMinLevel(const char* section);
74 
75 
76 
77 /**
78  * Returns the number of currently registered sections.
79  * @see #log_filter_section_getRegisteredIndex
80  */
81 int log_filter_section_getNumRegisteredSections();
82 
83 /**
84  * Returns a registered section.
85  */
86 const char* log_filter_section_getRegisteredIndex(int index);
87 
88 #define LOG_DISABLE() log_enable_and_disable(false)
89 #define LOG_ENABLE()  log_enable_and_disable(true)
90 
91 void log_enable_and_disable(const bool enable);
92 
93 #ifdef __cplusplus
94 } // extern "C"
95 #endif
96 
97 #ifdef __cplusplus
98 #include <set>
99 
100 
101 /**
102  * Returns the registered sections.
103  * This is simply to be more C++ friendly.
104  */
105 std::set<const char*> log_filter_section_getRegisteredSet();
106 
107 const char* log_filter_section_getSectionCString(const char* section_cstr_tmp);
108 
109 #endif
110 
111 /** @} */ // logging_filter_defaultFilter_control
112 
113 #endif // LOG_DEFAULT_FILTER_H
114 
115