13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24 #ifndef SHARE_VM_LOGGING_LOGTAGSET_HPP
25 #define SHARE_VM_LOGGING_LOGTAGSET_HPP
26
27 #include "logging/logDecorators.hpp"
28 #include "logging/logLevel.hpp"
29 #include "logging/logOutputList.hpp"
30 #include "logging/logTag.hpp"
31 #include "utilities/globalDefinitions.hpp"
32
33 // The tagset represents a combination of tags that occur in a log call somewhere.
34 // Tagsets are created automatically by the LogTagSetMappings and should never be
35 // instantiated directly somewhere else.
36 class LogTagSet VALUE_OBJ_CLASS_SPEC {
37 private:
38 static LogTagSet* _list;
39 static size_t _ntagsets;
40
41 LogTagSet* const _next;
42 size_t _ntags;
43 LogTagType _tag[LogTag::MaxTags];
44
45 LogOutputList _output_list;
46 LogDecorators _decorators;
47
48 // Keep constructor private to prevent incorrect instantiations of this class.
49 // Only LogTagSetMappings can create/contain instances of this class.
50 // The constructor links all tagsets together in a global list of tagsets.
51 // This list is used during configuration to be able to update all tagsets
52 // and their configurations to reflect the new global log configuration.
80 }
81 return false;
82 }
83
84 LogLevelType level_for(const LogOutput* output) const {
85 return _output_list.level_for(output);
86 }
87
88 void set_output_level(LogOutput* output, LogLevelType level) {
89 _output_list.set_output_level(output, level);
90 }
91
92 // Refresh the decorators for this tagset to contain the decorators for all
93 // of its current outputs combined with the given decorators.
94 void update_decorators(const LogDecorators& decorator = LogDecorators::None);
95
96 int label(char *buf, size_t len, const char* separator = ",") const;
97 bool has_output(const LogOutput* output);
98 bool is_level(LogLevelType level) const;
99 void log(LogLevelType level, const char* msg);
100 };
101
102 template <LogTagType T0, LogTagType T1 = LogTag::__NO_TAG, LogTagType T2 = LogTag::__NO_TAG,
103 LogTagType T3 = LogTag::__NO_TAG, LogTagType T4 = LogTag::__NO_TAG>
104 class LogTagSetMapping : public AllStatic {
105 private:
106 static LogTagSet _tagset;
107
108 public:
109 static LogTagSet& tagset() {
110 return _tagset;
111 }
112 };
113
114 // Instantiate the static field _tagset for all tagsets that are used for logging somewhere.
115 // (This must be done here rather than the .cpp file because it's a template.)
116 // Each combination of tags used as template arguments to the Log class somewhere (via macro or not)
117 // will instantiate the LogTagSetMapping template, which in turn creates the static field for that
118 // tagset. This _tagset contains the configuration for those tags.
119 template <LogTagType T0, LogTagType T1, LogTagType T2, LogTagType T3, LogTagType T4>
|
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24 #ifndef SHARE_VM_LOGGING_LOGTAGSET_HPP
25 #define SHARE_VM_LOGGING_LOGTAGSET_HPP
26
27 #include "logging/logDecorators.hpp"
28 #include "logging/logLevel.hpp"
29 #include "logging/logOutputList.hpp"
30 #include "logging/logTag.hpp"
31 #include "utilities/globalDefinitions.hpp"
32
33 class LogMessageBuffer;
34
35 // The tagset represents a combination of tags that occur in a log call somewhere.
36 // Tagsets are created automatically by the LogTagSetMappings and should never be
37 // instantiated directly somewhere else.
38 class LogTagSet VALUE_OBJ_CLASS_SPEC {
39 private:
40 static LogTagSet* _list;
41 static size_t _ntagsets;
42
43 LogTagSet* const _next;
44 size_t _ntags;
45 LogTagType _tag[LogTag::MaxTags];
46
47 LogOutputList _output_list;
48 LogDecorators _decorators;
49
50 // Keep constructor private to prevent incorrect instantiations of this class.
51 // Only LogTagSetMappings can create/contain instances of this class.
52 // The constructor links all tagsets together in a global list of tagsets.
53 // This list is used during configuration to be able to update all tagsets
54 // and their configurations to reflect the new global log configuration.
82 }
83 return false;
84 }
85
86 LogLevelType level_for(const LogOutput* output) const {
87 return _output_list.level_for(output);
88 }
89
90 void set_output_level(LogOutput* output, LogLevelType level) {
91 _output_list.set_output_level(output, level);
92 }
93
94 // Refresh the decorators for this tagset to contain the decorators for all
95 // of its current outputs combined with the given decorators.
96 void update_decorators(const LogDecorators& decorator = LogDecorators::None);
97
98 int label(char *buf, size_t len, const char* separator = ",") const;
99 bool has_output(const LogOutput* output);
100 bool is_level(LogLevelType level) const;
101 void log(LogLevelType level, const char* msg);
102 void log(const LogMessageBuffer& msg);
103 };
104
105 template <LogTagType T0, LogTagType T1 = LogTag::__NO_TAG, LogTagType T2 = LogTag::__NO_TAG,
106 LogTagType T3 = LogTag::__NO_TAG, LogTagType T4 = LogTag::__NO_TAG>
107 class LogTagSetMapping : public AllStatic {
108 private:
109 static LogTagSet _tagset;
110
111 public:
112 static LogTagSet& tagset() {
113 return _tagset;
114 }
115 };
116
117 // Instantiate the static field _tagset for all tagsets that are used for logging somewhere.
118 // (This must be done here rather than the .cpp file because it's a template.)
119 // Each combination of tags used as template arguments to the Log class somewhere (via macro or not)
120 // will instantiate the LogTagSetMapping template, which in turn creates the static field for that
121 // tagset. This _tagset contains the configuration for those tags.
122 template <LogTagType T0, LogTagType T1, LogTagType T2, LogTagType T3, LogTagType T4>
|