author | ihse |
Tue, 13 Feb 2018 10:37:33 +0100 | |
branch | ihse-remove-mapfiles-branch |
changeset 56106 | 40e61db323c2 |
parent 48824 | e48c4461a8bb |
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_LOGTAGLEVELEXPRESSION_HPP |
|
25 |
#define SHARE_VM_LOGGING_LOGTAGLEVELEXPRESSION_HPP |
|
26 |
||
34316
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
33097
diff
changeset
|
27 |
#include "logging/logConfiguration.hpp" |
33097 | 28 |
#include "logging/logLevel.hpp" |
29 |
#include "logging/logTag.hpp" |
|
30 |
#include "memory/allocation.hpp" |
|
31 |
#include "utilities/debug.hpp" |
|
32 |
#include "utilities/globalDefinitions.hpp" |
|
33 |
||
34 |
class LogTagSet; |
|
35 |
||
36 |
// Class used to temporary encode a 'what'-expression during log configuration. |
|
37 |
// Consists of a combination of tags and levels, e.g. "tag1+tag2=level1,tag3*=level2". |
|
38 |
class LogTagLevelExpression : public StackObj { |
|
37463
a4581cbe32cd
8153731: Increase max tag combinations for UL expression (config)
rehn
parents:
35852
diff
changeset
|
39 |
public: |
a4581cbe32cd
8153731: Increase max tag combinations for UL expression (config)
rehn
parents:
35852
diff
changeset
|
40 |
static const size_t MaxCombinations = 256; |
a4581cbe32cd
8153731: Increase max tag combinations for UL expression (config)
rehn
parents:
35852
diff
changeset
|
41 |
|
33097 | 42 |
private: |
48824 | 43 |
friend void LogConfiguration::configure_stdout(LogLevelType, int, ...); |
37463
a4581cbe32cd
8153731: Increase max tag combinations for UL expression (config)
rehn
parents:
35852
diff
changeset
|
44 |
|
33097 | 45 |
static const char* DefaultExpressionString; |
46 |
||
47 |
size_t _ntags, _ncombinations; |
|
48 |
LogTagType _tags[MaxCombinations][LogTag::MaxTags]; |
|
49 |
LogLevelType _level[MaxCombinations]; |
|
50 |
bool _allow_other_tags[MaxCombinations]; |
|
51 |
||
52 |
void new_combination() { |
|
35852
15ca44d4ae0c
8147348: LogTagLevelExpression not properly initialized in configure_stdout
mlarsson
parents:
34316
diff
changeset
|
53 |
// Make sure either all tags are set or the last tag is __NO_TAG |
15ca44d4ae0c
8147348: LogTagLevelExpression not properly initialized in configure_stdout
mlarsson
parents:
34316
diff
changeset
|
54 |
if (_ntags < LogTag::MaxTags) { |
15ca44d4ae0c
8147348: LogTagLevelExpression not properly initialized in configure_stdout
mlarsson
parents:
34316
diff
changeset
|
55 |
_tags[_ncombinations][_ntags] = LogTag::__NO_TAG; |
15ca44d4ae0c
8147348: LogTagLevelExpression not properly initialized in configure_stdout
mlarsson
parents:
34316
diff
changeset
|
56 |
} |
15ca44d4ae0c
8147348: LogTagLevelExpression not properly initialized in configure_stdout
mlarsson
parents:
34316
diff
changeset
|
57 |
|
33097 | 58 |
_ncombinations++; |
59 |
_ntags = 0; |
|
60 |
} |
|
61 |
||
40913
072bdbb90c13
8165215: Setting same UL tag multiple times matches wrong tagset
rehn
parents:
40884
diff
changeset
|
62 |
bool add_tag(LogTagType tag) { |
33097 | 63 |
assert(_ntags < LogTag::MaxTags, "Can't have more tags than MaxTags!"); |
40913
072bdbb90c13
8165215: Setting same UL tag multiple times matches wrong tagset
rehn
parents:
40884
diff
changeset
|
64 |
for (size_t i = 0; i < _ntags; i++) { |
072bdbb90c13
8165215: Setting same UL tag multiple times matches wrong tagset
rehn
parents:
40884
diff
changeset
|
65 |
if (_tags[_ncombinations][i] == tag) { |
072bdbb90c13
8165215: Setting same UL tag multiple times matches wrong tagset
rehn
parents:
40884
diff
changeset
|
66 |
return false; |
072bdbb90c13
8165215: Setting same UL tag multiple times matches wrong tagset
rehn
parents:
40884
diff
changeset
|
67 |
} |
072bdbb90c13
8165215: Setting same UL tag multiple times matches wrong tagset
rehn
parents:
40884
diff
changeset
|
68 |
} |
33097 | 69 |
_tags[_ncombinations][_ntags++] = tag; |
40913
072bdbb90c13
8165215: Setting same UL tag multiple times matches wrong tagset
rehn
parents:
40884
diff
changeset
|
70 |
return true; |
33097 | 71 |
} |
72 |
||
73 |
void set_level(LogLevelType level) { |
|
74 |
_level[_ncombinations] = level; |
|
75 |
} |
|
76 |
||
77 |
void set_allow_other_tags() { |
|
78 |
_allow_other_tags[_ncombinations] = true; |
|
79 |
} |
|
80 |
||
81 |
public: |
|
34316
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
33097
diff
changeset
|
82 |
LogTagLevelExpression() : _ntags(0), _ncombinations(0) { |
35852
15ca44d4ae0c
8147348: LogTagLevelExpression not properly initialized in configure_stdout
mlarsson
parents:
34316
diff
changeset
|
83 |
for (size_t combination = 0; combination < MaxCombinations; combination++) { |
15ca44d4ae0c
8147348: LogTagLevelExpression not properly initialized in configure_stdout
mlarsson
parents:
34316
diff
changeset
|
84 |
_level[combination] = LogLevel::Invalid; |
15ca44d4ae0c
8147348: LogTagLevelExpression not properly initialized in configure_stdout
mlarsson
parents:
34316
diff
changeset
|
85 |
_allow_other_tags[combination] = false; |
15ca44d4ae0c
8147348: LogTagLevelExpression not properly initialized in configure_stdout
mlarsson
parents:
34316
diff
changeset
|
86 |
_tags[combination][0] = LogTag::__NO_TAG; |
15ca44d4ae0c
8147348: LogTagLevelExpression not properly initialized in configure_stdout
mlarsson
parents:
34316
diff
changeset
|
87 |
} |
33097 | 88 |
} |
89 |
||
90 |
bool parse(const char* str, outputStream* errstream = NULL); |
|
91 |
LogLevelType level_for(const LogTagSet& ts) const; |
|
40884
0e28c526f5d3
8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents:
37463
diff
changeset
|
92 |
|
0e28c526f5d3
8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents:
37463
diff
changeset
|
93 |
// Verify the tagsets/selections mentioned in this expression. |
0e28c526f5d3
8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents:
37463
diff
changeset
|
94 |
// Returns false if some invalid tagset was found. If given an outputstream, |
0e28c526f5d3
8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents:
37463
diff
changeset
|
95 |
// this function will list all the invalid selections on the stream. |
0e28c526f5d3
8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents:
37463
diff
changeset
|
96 |
bool verify_tagsets(outputStream* out = NULL) const; |
33097 | 97 |
}; |
98 |
||
99 |
#endif // SHARE_VM_LOGGING_LOGTAGLEVELEXPRESSION_HPP |