src/hotspot/share/logging/logTagLevelExpression.cpp
author kaddepalli
Wed, 28 Feb 2018 14:29:37 +0530
changeset 49105 cd1d231b2c33
parent 47216 71c04702a3d5
permissions -rw-r--r--
8197808: Test java/awt/Dialog/MakeWindowAlwaysOnTop/MakeWindowAlwaysOnTop.java fails on Windows Reviewed-by: ssadetsky, prr, serb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33097
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
     1
/*
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
     4
 *
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
     7
 * published by the Free Software Foundation.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
     8
 *
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    13
 * accompanied this code).
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    14
 *
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    18
 *
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    21
 * questions.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    22
 *
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    23
 */
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    24
#include "precompiled.hpp"
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    25
#include "logging/logTagLevelExpression.hpp"
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    26
#include "logging/logTagSet.hpp"
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    27
#include "runtime/arguments.hpp"
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    28
#include "runtime/os.inline.hpp"
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    29
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    30
const char* LogTagLevelExpression::DefaultExpressionString = "all";
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    31
40884
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    32
static bool matches_tagset(const LogTagType tags[],
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    33
                           bool allow_other_tags,
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    34
                           const LogTagSet& ts) {
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    35
  bool contains_all = true;
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    36
  size_t tag_idx;
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    37
  for (tag_idx = 0; tag_idx < LogTag::MaxTags && tags[tag_idx] != LogTag::__NO_TAG; tag_idx++) {
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    38
    if (!ts.contains(tags[tag_idx])) {
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    39
      contains_all = false;
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    40
      break;
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    41
    }
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    42
  }
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    43
  // All tags in the expression must be part of the tagset,
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    44
  // and either the expression allows other tags (has a wildcard),
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    45
  // or the number of tags in the expression and tagset must match.
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    46
  return contains_all && (allow_other_tags || tag_idx == ts.ntags());
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    47
}
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    48
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    49
bool LogTagLevelExpression::verify_tagsets(outputStream* out) const {
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    50
  bool valid = true;
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    51
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    52
  for (size_t i = 0; i < _ncombinations; i++) {
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    53
    bool matched = false;
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    54
    for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) {
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    55
      if (matches_tagset(_tags[i], _allow_other_tags[i], *ts)) {
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    56
        matched = true;
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    57
        break;
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    58
      }
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    59
    }
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    60
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    61
    if (!matched) {
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    62
      // If this was the first invalid combination, write the message header
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    63
      if (valid && out != NULL) {
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    64
        out->print("No tag set matches selection(s): ");
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    65
      }
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    66
      valid = false;
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    67
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    68
      // Break as soon as possible unless listing all invalid combinations
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    69
      if (out == NULL) {
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    70
        break;
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    71
      }
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    72
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    73
      // List the combination on the outputStream
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    74
      for (size_t t = 0; t < LogTag::MaxTags && _tags[i][t] != LogTag::__NO_TAG; t++) {
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    75
        out->print("%s%s", (t == 0 ? "" : "+"), LogTag::name(_tags[i][t]));
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    76
      }
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    77
      if (_allow_other_tags[i]) {
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    78
        out->print("*");
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    79
      }
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    80
      out->print(" ");
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    81
    }
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    82
  }
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    83
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    84
  if (!valid && out != NULL) {
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    85
    out->cr();
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    86
  }
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    87
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    88
  return valid;
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    89
}
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
    90
33097
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    91
bool LogTagLevelExpression::parse(const char* str, outputStream* errstream) {
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    92
  bool success = true;
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    93
  if (str == NULL || strcmp(str, "") == 0) {
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    94
    str = DefaultExpressionString;
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    95
  }
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    96
  char* copy = os::strdup_check_oom(str, mtLogging);
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    97
  // Split string on commas
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    98
  for (char *comma_pos = copy, *cur = copy; success && comma_pos != NULL; cur = comma_pos + 1) {
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    99
    if (_ncombinations == MaxCombinations) {
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   100
      if (errstream != NULL) {
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   101
        errstream->print_cr("Can not have more than " SIZE_FORMAT " tag combinations in a what-expression.",
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   102
                            MaxCombinations);
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   103
      }
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   104
      success = false;
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   105
      break;
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   106
    }
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   107
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   108
    comma_pos = strchr(cur, ',');
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   109
    if (comma_pos != NULL) {
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   110
      *comma_pos = '\0';
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   111
    }
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   112
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   113
    // Parse the level, if specified
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   114
    LogLevelType level = LogLevel::Unspecified;
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   115
    char* equals = strchr(cur, '=');
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   116
    if (equals != NULL) {
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   117
      level = LogLevel::from_string(equals + 1);
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   118
      if (level == LogLevel::Invalid) {
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   119
        if (errstream != NULL) {
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   120
          errstream->print_cr("Invalid level '%s' in what-expression.", equals + 1);
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   121
        }
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   122
        success = false;
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   123
        break;
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   124
      }
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   125
      *equals = '\0'; // now ignore "=level" part of substr
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   126
    }
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   127
    set_level(level);
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   128
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   129
    // Parse special tags such as 'all'
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   130
    if (strcmp(cur, "all") == 0) {
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   131
      set_allow_other_tags();
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   132
      new_combination();
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   133
      continue;
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   134
    }
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   135
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   136
    // Check for '*' suffix
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   137
    char* asterisk_pos = strchr(cur, '*');
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   138
    if (asterisk_pos != NULL && asterisk_pos[1] == '\0') {
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   139
      set_allow_other_tags();
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   140
      *asterisk_pos = '\0';
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   141
    }
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   142
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   143
    // Parse the tag expression (t1+t2+...+tn)
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   144
    char* plus_pos;
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   145
    char* cur_tag = cur;
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   146
    do {
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   147
      plus_pos = strchr(cur_tag, '+');
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   148
      if (plus_pos != NULL) {
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   149
        *plus_pos = '\0';
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   150
      }
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   151
      LogTagType tag = LogTag::from_string(cur_tag);
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   152
      if (tag == LogTag::__NO_TAG) {
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   153
        if (errstream != NULL) {
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   154
          errstream->print_cr("Invalid tag '%s' in what-expression.", cur_tag);
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   155
        }
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   156
        success = false;
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   157
        break;
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   158
      }
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   159
      if (_ntags == LogTag::MaxTags) {
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   160
        if (errstream != NULL) {
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   161
          errstream->print_cr("Tag combination exceeds the maximum of " SIZE_FORMAT " tags.",
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   162
                              LogTag::MaxTags);
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   163
        }
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   164
        success = false;
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   165
        break;
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   166
      }
40913
072bdbb90c13 8165215: Setting same UL tag multiple times matches wrong tagset
rehn
parents: 40884
diff changeset
   167
      if (!add_tag(tag)) {
072bdbb90c13 8165215: Setting same UL tag multiple times matches wrong tagset
rehn
parents: 40884
diff changeset
   168
        if (errstream != NULL) {
072bdbb90c13 8165215: Setting same UL tag multiple times matches wrong tagset
rehn
parents: 40884
diff changeset
   169
          errstream->print_cr("Tag combination have duplicate tag '%s' in what-expression.",
072bdbb90c13 8165215: Setting same UL tag multiple times matches wrong tagset
rehn
parents: 40884
diff changeset
   170
                              cur_tag);
072bdbb90c13 8165215: Setting same UL tag multiple times matches wrong tagset
rehn
parents: 40884
diff changeset
   171
        }
072bdbb90c13 8165215: Setting same UL tag multiple times matches wrong tagset
rehn
parents: 40884
diff changeset
   172
        success = false;
072bdbb90c13 8165215: Setting same UL tag multiple times matches wrong tagset
rehn
parents: 40884
diff changeset
   173
        break;
072bdbb90c13 8165215: Setting same UL tag multiple times matches wrong tagset
rehn
parents: 40884
diff changeset
   174
      }
33097
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   175
      cur_tag = plus_pos + 1;
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   176
    } while (plus_pos != NULL);
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   177
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   178
    new_combination();
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   179
  }
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   180
34316
4d876653d940 8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents: 33097
diff changeset
   181
  os::free(copy);
33097
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   182
  return success;
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   183
}
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   184
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   185
LogLevelType LogTagLevelExpression::level_for(const LogTagSet& ts) const {
34316
4d876653d940 8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents: 33097
diff changeset
   186
  // Return NotMentioned if the given tagset isn't covered by this expression.
4d876653d940 8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents: 33097
diff changeset
   187
  LogLevelType level = LogLevel::NotMentioned;
33097
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   188
  for (size_t combination = 0; combination < _ncombinations; combination++) {
40884
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
   189
    if (matches_tagset(_tags[combination], _allow_other_tags[combination], ts)) {
33097
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   190
      level = _level[combination];
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   191
    }
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   192
  }
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   193
  return level;
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   194
}
40884
0e28c526f5d3 8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents: 35852
diff changeset
   195