src/hotspot/share/logging/logConfiguration.hpp
author gziemski
Fri, 26 Oct 2018 10:47:05 -0500
changeset 52304 72f2fc52ef85
parent 49180 9637557def32
child 53244 9807daeb47c4
permissions -rw-r--r--
8017061: os_bsd.cpp contains code for UseSHM and UseHugeTLBFS Summary: Removed the code using unused flags. Reviewed-by: dholmes, coleenp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33097
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
     1
/*
49016
ea85eed8b012 8196783: Refactor LogTagLevelExpression into separate classes
mlarsson
parents: 48824
diff changeset
     2
 * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
33097
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
34316
4d876653d940 8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents: 33097
diff changeset
    27
#include "logging/logLevel.hpp"
33097
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    28
#include "memory/allocation.hpp"
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    29
#include "utilities/globalDefinitions.hpp"
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    30
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    31
class LogOutput;
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    32
class LogDecorators;
49016
ea85eed8b012 8196783: Refactor LogTagLevelExpression into separate classes
mlarsson
parents: 48824
diff changeset
    33
class LogSelectionList;
33097
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    34
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    35
// Global configuration of logging. Handles parsing and configuration of the logging framework,
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    36
// 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
    37
// kept implicitly in the LogTagSets and their LogOutputLists. During configuration the tagsets
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    38
// are iterated over and updated accordingly.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    39
class LogConfiguration : public AllStatic {
37994
1a816b464178 8151526: Print -Xlog configuration in the hs_err_pid file
mockner
parents: 37108
diff changeset
    40
 friend class VMError;
49171
6ecca4a9c75f 8170976: [TESTBUG] LogTestFixture does not restore previous logging state
mlarsson
parents: 49016
diff changeset
    41
 friend class LogTestFixture;
37108
fe800ec86077 8151264: Add a notification mechanism for UL configuration changes.
rehn
parents: 35230
diff changeset
    42
 public:
fe800ec86077 8151264: Add a notification mechanism for UL configuration changes.
rehn
parents: 35230
diff changeset
    43
  // Function for listeners
fe800ec86077 8151264: Add a notification mechanism for UL configuration changes.
rehn
parents: 35230
diff changeset
    44
  typedef void (*UpdateListenerFunction)(void);
fe800ec86077 8151264: Add a notification mechanism for UL configuration changes.
rehn
parents: 35230
diff changeset
    45
fe800ec86077 8151264: Add a notification mechanism for UL configuration changes.
rehn
parents: 35230
diff changeset
    46
  // Register callback for config change.
fe800ec86077 8151264: Add a notification mechanism for UL configuration changes.
rehn
parents: 35230
diff changeset
    47
  // The callback is always called with ConfigurationLock held,
fe800ec86077 8151264: Add a notification mechanism for UL configuration changes.
rehn
parents: 35230
diff changeset
    48
  // hence doing log reconfiguration from the callback will deadlock.
fe800ec86077 8151264: Add a notification mechanism for UL configuration changes.
rehn
parents: 35230
diff changeset
    49
  // The main Java thread may call this callback if there is an early registration
fe800ec86077 8151264: Add a notification mechanism for UL configuration changes.
rehn
parents: 35230
diff changeset
    50
  // else the attach listener JavaThread, started via diagnostic command, will be executing thread.
fe800ec86077 8151264: Add a notification mechanism for UL configuration changes.
rehn
parents: 35230
diff changeset
    51
  // The main purpose of this callback is to see if a loglevel have been changed.
fe800ec86077 8151264: Add a notification mechanism for UL configuration changes.
rehn
parents: 35230
diff changeset
    52
  // There is no way to unregister.
fe800ec86077 8151264: Add a notification mechanism for UL configuration changes.
rehn
parents: 35230
diff changeset
    53
  static void register_update_listener(UpdateListenerFunction cb);
fe800ec86077 8151264: Add a notification mechanism for UL configuration changes.
rehn
parents: 35230
diff changeset
    54
33097
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    55
 private:
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    56
  static LogOutput**  _outputs;
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    57
  static size_t       _n_outputs;
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    58
37108
fe800ec86077 8151264: Add a notification mechanism for UL configuration changes.
rehn
parents: 35230
diff changeset
    59
  static UpdateListenerFunction*    _listener_callbacks;
fe800ec86077 8151264: Add a notification mechanism for UL configuration changes.
rehn
parents: 35230
diff changeset
    60
  static size_t                     _n_listener_callbacks;
fe800ec86077 8151264: Add a notification mechanism for UL configuration changes.
rehn
parents: 35230
diff changeset
    61
33097
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    62
  // Create a new output. Returns NULL if failed.
40902
395e1f3ec886 8157948: UL allows same log file with multiple file=
mlarsson
parents: 37994
diff changeset
    63
  static LogOutput* new_output(const char* name, const char* options, outputStream* errstream);
33097
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    64
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    65
  // Add an output to the list of configured outputs. Returns the assigned index.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    66
  static size_t add_output(LogOutput* out);
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    67
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    68
  // Delete a configured output. The stderr/stdout outputs can not be removed.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    69
  // Output should be completely disabled before it is deleted.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    70
  static void delete_output(size_t idx);
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    71
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    72
  // 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
    73
  static void disable_output(size_t idx);
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    74
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    75
  // Get output index by name. Returns SIZE_MAX if output not found.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    76
  static size_t find_output(const char* name);
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    77
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    78
  // Configure output (add or update existing configuration) to log on tag-level combination using specified decorators.
49016
ea85eed8b012 8196783: Refactor LogTagLevelExpression into separate classes
mlarsson
parents: 48824
diff changeset
    79
  static void configure_output(size_t idx, const LogSelectionList& tag_level_expression, const LogDecorators& decorators);
33097
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    80
37108
fe800ec86077 8151264: Add a notification mechanism for UL configuration changes.
rehn
parents: 35230
diff changeset
    81
  // This should be called after any configuration change while still holding ConfigurationLock
fe800ec86077 8151264: Add a notification mechanism for UL configuration changes.
rehn
parents: 35230
diff changeset
    82
  static void notify_update_listeners();
fe800ec86077 8151264: Add a notification mechanism for UL configuration changes.
rehn
parents: 35230
diff changeset
    83
37994
1a816b464178 8151526: Print -Xlog configuration in the hs_err_pid file
mockner
parents: 37108
diff changeset
    84
  // Respectively describe the built-in and runtime dependent portions of the configuration.
1a816b464178 8151526: Print -Xlog configuration in the hs_err_pid file
mockner
parents: 37108
diff changeset
    85
  static void describe_available(outputStream* out);
1a816b464178 8151526: Print -Xlog configuration in the hs_err_pid file
mockner
parents: 37108
diff changeset
    86
  static void describe_current_configuration(outputStream* out);
1a816b464178 8151526: Print -Xlog configuration in the hs_err_pid file
mockner
parents: 37108
diff changeset
    87
1a816b464178 8151526: Print -Xlog configuration in the hs_err_pid file
mockner
parents: 37108
diff changeset
    88
33097
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    89
 public:
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    90
  // 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
    91
  static void initialize(jlong vm_start_time);
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    92
  static void finalize();
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    93
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    94
  // Perform necessary post-initialization after VM startup. Enables reconfiguration of logging.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    95
  static void post_initialize();
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    96
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    97
  // Disable all logging, equivalent to -Xlog:disable.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    98
  static void disable_logging();
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    99
34316
4d876653d940 8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents: 33097
diff changeset
   100
  // Configures logging on stdout for the given tags and level combination.
4d876653d940 8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents: 33097
diff changeset
   101
  // Intended for mappings between -XX: flags and Unified Logging configuration.
4d876653d940 8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents: 33097
diff changeset
   102
  // If exact_match is true, only tagsets with precisely the specified tags will be configured
4d876653d940 8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents: 33097
diff changeset
   103
  // (exact_match=false is the same as "-Xlog:<tags>*=<level>", and exact_match=true is "-Xlog:<tags>=<level>").
4d876653d940 8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents: 33097
diff changeset
   104
  // Tags should be specified using the LOG_TAGS macro, e.g.
4d876653d940 8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents: 33097
diff changeset
   105
  // LogConfiguration::configure_stdout(LogLevel::<level>, <true/false>, LOG_TAGS(<tags>));
48824
e48c4461a8bb 8181503: Can't compile hotspot with c++11
gziemski
parents: 47216
diff changeset
   106
  static void configure_stdout(LogLevelType level, int exact_match, ...);
34316
4d876653d940 8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents: 33097
diff changeset
   107
33097
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   108
  // 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
   109
  static bool parse_command_line_arguments(const char* opts = "all");
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   110
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   111
  // Parse separated configuration arguments (from JCmd/MBean and command line).
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   112
  static bool parse_log_arguments(const char* outputstr,
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   113
                                  const char* what,
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   114
                                  const char* decoratorstr,
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   115
                                  const char* output_options,
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   116
                                  outputStream* errstream);
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   117
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   118
  // Prints log configuration to outputStream, used by JCmd/MBean.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   119
  static void describe(outputStream* out);
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   120
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   121
  // Prints usage help for command line log configuration.
49180
9637557def32 8190346: improve unified JVM logging help message and warnings
mlarsson
parents: 49171
diff changeset
   122
  static void print_command_line_help(outputStream* out);
34637
9b9298044d23 8140556: Add force rotation option to VM.log jcmd
ysuenaga
parents: 34316
diff changeset
   123
9b9298044d23 8140556: Add force rotation option to VM.log jcmd
ysuenaga
parents: 34316
diff changeset
   124
  // Rotates all LogOutput
9b9298044d23 8140556: Add force rotation option to VM.log jcmd
ysuenaga
parents: 34316
diff changeset
   125
  static void rotate_all_outputs();
33097
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   126
};
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   127
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   128
#endif // SHARE_VM_LOGGING_LOGCONFIGURATION_HPP