annotate src/share/vm/logging/logTagLevelExpression.hpp @ 10867:78eaba1e0d24

8153731: Increase max tag combinations for UL expression (config) Reviewed-by: stefank, mlarsson
author rehn
date Fri, 08 Apr 2016 15:36:34 +0200
parents a910db847a63
children 6ac1e2e55eaa
rev   line source
mlarsson@9046 1 /*
mlarsson@9046 2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
mlarsson@9046 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
mlarsson@9046 4 *
mlarsson@9046 5 * This code is free software; you can redistribute it and/or modify it
mlarsson@9046 6 * under the terms of the GNU General Public License version 2 only, as
mlarsson@9046 7 * published by the Free Software Foundation.
mlarsson@9046 8 *
mlarsson@9046 9 * This code is distributed in the hope that it will be useful, but WITHOUT
mlarsson@9046 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
mlarsson@9046 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
mlarsson@9046 12 * version 2 for more details (a copy is included in the LICENSE file that
mlarsson@9046 13 * accompanied this code).
mlarsson@9046 14 *
mlarsson@9046 15 * You should have received a copy of the GNU General Public License version
mlarsson@9046 16 * 2 along with this work; if not, write to the Free Software Foundation,
mlarsson@9046 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
mlarsson@9046 18 *
mlarsson@9046 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
mlarsson@9046 20 * or visit www.oracle.com if you need additional information or have any
mlarsson@9046 21 * questions.
mlarsson@9046 22 *
mlarsson@9046 23 */
mlarsson@9046 24 #ifndef SHARE_VM_LOGGING_LOGTAGLEVELEXPRESSION_HPP
mlarsson@9046 25 #define SHARE_VM_LOGGING_LOGTAGLEVELEXPRESSION_HPP
mlarsson@9046 26
mlarsson@9578 27 #include "logging/logConfiguration.hpp"
mlarsson@9046 28 #include "logging/logLevel.hpp"
mlarsson@9046 29 #include "logging/logTag.hpp"
mlarsson@9046 30 #include "memory/allocation.hpp"
mlarsson@9046 31 #include "utilities/debug.hpp"
mlarsson@9046 32 #include "utilities/globalDefinitions.hpp"
mlarsson@9046 33
mlarsson@9046 34 class LogTagSet;
mlarsson@9046 35
mlarsson@9046 36 // Class used to temporary encode a 'what'-expression during log configuration.
mlarsson@9046 37 // Consists of a combination of tags and levels, e.g. "tag1+tag2=level1,tag3*=level2".
mlarsson@9046 38 class LogTagLevelExpression : public StackObj {
rehn@10867 39 public:
rehn@10867 40 static const size_t MaxCombinations = 256;
rehn@10867 41
rehn@10867 42 private:
mlarsson@9578 43 friend void LogConfiguration::configure_stdout(LogLevelType, bool, ...);
rehn@10867 44
mlarsson@9046 45 static const char* DefaultExpressionString;
mlarsson@9046 46
mlarsson@9046 47 size_t _ntags, _ncombinations;
mlarsson@9046 48 LogTagType _tags[MaxCombinations][LogTag::MaxTags];
mlarsson@9046 49 LogLevelType _level[MaxCombinations];
mlarsson@9046 50 bool _allow_other_tags[MaxCombinations];
mlarsson@9046 51
mlarsson@9046 52 void new_combination() {
mlarsson@10112 53 // Make sure either all tags are set or the last tag is __NO_TAG
mlarsson@10112 54 if (_ntags < LogTag::MaxTags) {
mlarsson@10112 55 _tags[_ncombinations][_ntags] = LogTag::__NO_TAG;
mlarsson@10112 56 }
mlarsson@10112 57
mlarsson@9046 58 _ncombinations++;
mlarsson@9046 59 _ntags = 0;
mlarsson@9046 60 }
mlarsson@9046 61
mlarsson@9046 62 void add_tag(LogTagType tag) {
mlarsson@9046 63 assert(_ntags < LogTag::MaxTags, "Can't have more tags than MaxTags!");
mlarsson@9046 64 _tags[_ncombinations][_ntags++] = tag;
mlarsson@9046 65 }
mlarsson@9046 66
mlarsson@9046 67 void set_level(LogLevelType level) {
mlarsson@9046 68 _level[_ncombinations] = level;
mlarsson@9046 69 }
mlarsson@9046 70
mlarsson@9046 71 void set_allow_other_tags() {
mlarsson@9046 72 _allow_other_tags[_ncombinations] = true;
mlarsson@9046 73 }
mlarsson@9046 74
mlarsson@9046 75 public:
mlarsson@9578 76 LogTagLevelExpression() : _ntags(0), _ncombinations(0) {
mlarsson@10112 77 for (size_t combination = 0; combination < MaxCombinations; combination++) {
mlarsson@10112 78 _level[combination] = LogLevel::Invalid;
mlarsson@10112 79 _allow_other_tags[combination] = false;
mlarsson@10112 80 _tags[combination][0] = LogTag::__NO_TAG;
mlarsson@10112 81 }
mlarsson@9046 82 }
mlarsson@9046 83
mlarsson@9046 84 bool parse(const char* str, outputStream* errstream = NULL);
mlarsson@9046 85 LogLevelType level_for(const LogTagSet& ts) const;
mlarsson@9046 86 };
mlarsson@9046 87
mlarsson@9046 88 #endif // SHARE_VM_LOGGING_LOGTAGLEVELEXPRESSION_HPP