author | mlarsson |
Fri, 04 Dec 2015 13:02:25 +0100 | |
changeset 34656 | 501b8f1784c4 |
parent 34629 | d1e1bfdca413 |
child 35061 | be6025ebffea |
permissions | -rw-r--r-- |
33097 | 1 |
/* |
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
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_LOGTAG_HPP |
|
25 |
#define SHARE_VM_LOGGING_LOGTAG_HPP |
|
26 |
||
27 |
#include "memory/allocation.hpp" |
|
28 |
#include "utilities/globalDefinitions.hpp" |
|
29 |
||
30 |
// List of available logging tags. New tags should be added here. |
|
31 |
// (The tags 'all', 'disable' and 'help' are special tags that can |
|
32 |
// not be used in log calls, and should not be listed below.) |
|
33 |
#define LOG_TAG_LIST \ |
|
34628
6d08ec72803b
8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
33763
diff
changeset
|
34 |
LOG_TAG(classinit) \ |
33736
1b3950243443
8139564: Convert TraceDefaultMethods to Unified Logging
rprotacio
parents:
33097
diff
changeset
|
35 |
LOG_TAG(defaultmethods) \ |
34150
ec723a529700
8144016: Add the gc tag to the logging framework
brutisso
parents:
33763
diff
changeset
|
36 |
LOG_TAG(gc) \ |
33763
cec2333f839c
8140348: Convert TraceSafepoint to Unified Logging
rprotacio
parents:
33736
diff
changeset
|
37 |
LOG_TAG(logging) \ |
34262
43560e879d6d
8143157: Convert TraceVMOperation to Unified Logging
rprotacio
parents:
33763
diff
changeset
|
38 |
LOG_TAG(safepoint) \ |
43560e879d6d
8143157: Convert TraceVMOperation to Unified Logging
rprotacio
parents:
33763
diff
changeset
|
39 |
LOG_TAG(vmoperation) |
33097 | 40 |
|
34656
501b8f1784c4
8144146: Unified Logging tags cannot be reserved keywords
mlarsson
parents:
34629
diff
changeset
|
41 |
#define PREFIX_LOG_TAG(T) (LogTag::_##T) |
33097 | 42 |
|
43 |
// Expand a set of log tags to their prefixed names. |
|
44 |
// For error detection purposes, the macro passes one more tag than what is supported. |
|
45 |
// If too many tags are given, a static assert in the log class will fail. |
|
46 |
#define LOG_TAGS_EXPANDED(T0, T1, T2, T3, T4, T5, ...) PREFIX_LOG_TAG(T0), PREFIX_LOG_TAG(T1), PREFIX_LOG_TAG(T2), \ |
|
47 |
PREFIX_LOG_TAG(T3), PREFIX_LOG_TAG(T4), PREFIX_LOG_TAG(T5) |
|
48 |
// The EXPAND_VARARGS macro is required for MSVC, or it will resolve the LOG_TAGS_EXPANDED macro incorrectly. |
|
49 |
#define EXPAND_VARARGS(x) x |
|
34656
501b8f1784c4
8144146: Unified Logging tags cannot be reserved keywords
mlarsson
parents:
34629
diff
changeset
|
50 |
#define LOG_TAGS(...) EXPAND_VARARGS(LOG_TAGS_EXPANDED(__VA_ARGS__, _NO_TAG, _NO_TAG, _NO_TAG, _NO_TAG, _NO_TAG, _NO_TAG)) |
33097 | 51 |
|
52 |
// Log tags are used to classify log messages. |
|
53 |
// Each log message can be assigned between 1 to LogTag::MaxTags number of tags. |
|
54 |
// Specifying multiple tags for a log message means that only outputs configured |
|
55 |
// for those exact tags, or a subset of the tags with a wildcard, will see the logging. |
|
56 |
// Multiple tags should be comma separated, e.g. log_error(tag1, tag2)("msg"). |
|
57 |
class LogTag : public AllStatic { |
|
58 |
public: |
|
59 |
// The maximum number of tags that a single log message can have. |
|
60 |
// E.g. there might be hundreds of different tags available, |
|
61 |
// but a specific log message can only be tagged with up to MaxTags of those. |
|
62 |
static const size_t MaxTags = 5; |
|
63 |
||
64 |
enum type { |
|
65 |
__NO_TAG, |
|
34656
501b8f1784c4
8144146: Unified Logging tags cannot be reserved keywords
mlarsson
parents:
34629
diff
changeset
|
66 |
#define LOG_TAG(name) _##name, |
33097 | 67 |
LOG_TAG_LIST |
68 |
#undef LOG_TAG |
|
69 |
Count |
|
70 |
}; |
|
71 |
||
72 |
static const char* name(LogTag::type tag) { |
|
73 |
return _name[tag]; |
|
74 |
} |
|
75 |
||
76 |
static LogTag::type from_string(const char *str); |
|
77 |
||
78 |
private: |
|
79 |
static const char* _name[]; |
|
80 |
}; |
|
81 |
||
82 |
typedef LogTag::type LogTagType; |
|
83 |
||
84 |
#endif // SHARE_VM_LOGGING_LOGTAG_HPP |