hotspot/src/share/vm/logging/logConfiguration.hpp
author mlarsson
Thu, 24 Sep 2015 12:36:04 +0200
changeset 33097 96e348cb0442
child 34316 4d876653d940
permissions -rw-r--r--
8046148: JEP 158: Unified JVM Logging Reviewed-by: coleenp, sla
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
#ifndef SHARE_VM_LOGGING_LOGCONFIGURATION_HPP
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    25
#define SHARE_VM_LOGGING_LOGCONFIGURATION_HPP
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    26
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    27
#include "memory/allocation.hpp"
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    28
#include "utilities/globalDefinitions.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
class LogOutput;
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    31
class LogDecorators;
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    32
class LogTagLevelExpression;
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    33
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    34
// Global configuration of logging. Handles parsing and configuration of the logging framework,
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    35
// and manages the list of configured log outputs. The actual tag and level configuration is
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    36
// kept implicitly in the LogTagSets and their LogOutputLists. During configuration the tagsets
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    37
// are iterated over and updated accordingly.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    38
class LogConfiguration : public AllStatic {
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    39
 private:
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    40
  static LogOutput**  _outputs;
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    41
  static size_t       _n_outputs;
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    42
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    43
  // Create a new output. Returns NULL if failed.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    44
  static LogOutput* new_output(char* name, const char* options = NULL);
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    45
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    46
  // Add an output to the list of configured outputs. Returns the assigned index.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    47
  static size_t add_output(LogOutput* out);
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    48
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    49
  // Delete a configured output. The stderr/stdout outputs can not be removed.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    50
  // Output should be completely disabled before it is deleted.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    51
  static void delete_output(size_t idx);
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    52
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    53
  // Disable all logging to the specified output and then delete it (unless it is stdout/stderr).
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    54
  static void disable_output(size_t idx);
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    55
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    56
  // Get output index by name. Returns SIZE_MAX if output not found.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    57
  static size_t find_output(const char* name);
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    58
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    59
  // Configure output (add or update existing configuration) to log on tag-level combination using specified decorators.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    60
  static void configure_output(size_t idx, const LogTagLevelExpression& tag_level_expression, const LogDecorators& decorators);
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    61
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    62
 public:
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    63
  // Initialization and finalization of log configuration, to be run at vm startup and shutdown respectively.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    64
  static void initialize(jlong vm_start_time);
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    65
  static void finalize();
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    66
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    67
  // Perform necessary post-initialization after VM startup. Enables reconfiguration of logging.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    68
  static void post_initialize();
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    69
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    70
  // Disable all logging, equivalent to -Xlog:disable.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    71
  static void disable_logging();
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    72
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    73
  // Parse command line configuration. Parameter 'opts' is the string immediately following the -Xlog: argument ("gc" for -Xlog:gc).
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    74
  static bool parse_command_line_arguments(const char* opts = "all");
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    75
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    76
  // Parse separated configuration arguments (from JCmd/MBean and command line).
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    77
  static bool parse_log_arguments(const char* outputstr,
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    78
                                  const char* what,
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    79
                                  const char* decoratorstr,
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    80
                                  const char* output_options,
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    81
                                  outputStream* errstream);
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    82
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    83
  // Prints log configuration to outputStream, used by JCmd/MBean.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    84
  static void describe(outputStream* out);
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    85
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    86
  // Prints usage help for command line log configuration.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    87
  static void print_command_line_help(FILE* out);
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    88
};
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    89
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    90
#endif // SHARE_VM_LOGGING_LOGCONFIGURATION_HPP