Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/logging/logConfiguration.hpp
40930 views
1
/*
2
* Copyright (c) 2015, 2019, 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_LOGGING_LOGCONFIGURATION_HPP
25
#define SHARE_LOGGING_LOGCONFIGURATION_HPP
26
27
#include "logging/logLevel.hpp"
28
#include "memory/allocation.hpp"
29
#include "utilities/globalDefinitions.hpp"
30
31
class LogOutput;
32
class LogDecorators;
33
class LogSelectionList;
34
35
// Global configuration of logging. Handles parsing and configuration of the logging framework,
36
// and manages the list of configured log outputs. The actual tag and level configuration is
37
// kept implicitly in the LogTagSets and their LogOutputLists. During configuration the tagsets
38
// are iterated over and updated accordingly.
39
class LogConfiguration : public AllStatic {
40
friend class VMError;
41
friend class LogTestFixture;
42
public:
43
// Function for listeners
44
typedef void (*UpdateListenerFunction)(void);
45
46
// Register callback for config change.
47
// The callback is always called with ConfigurationLock held,
48
// hence doing log reconfiguration from the callback will deadlock.
49
// The main Java thread may call this callback if there is an early registration
50
// else the attach listener JavaThread, started via diagnostic command, will be executing thread.
51
// The main purpose of this callback is to see if a loglevel have been changed.
52
// There is no way to unregister.
53
static void register_update_listener(UpdateListenerFunction cb);
54
55
private:
56
static LogOutput** _outputs;
57
static size_t _n_outputs;
58
59
static UpdateListenerFunction* _listener_callbacks;
60
static size_t _n_listener_callbacks;
61
static bool _async_mode;
62
63
// Create a new output. Returns NULL if failed.
64
static LogOutput* new_output(const char* name, const char* options, outputStream* errstream);
65
66
// Add an output to the list of configured outputs. Returns the assigned index.
67
static size_t add_output(LogOutput* out);
68
69
// Delete a configured output. The stderr/stdout outputs can not be removed.
70
// Output should be completely disabled before it is deleted.
71
static void delete_output(size_t idx);
72
73
// Disable all logging to all outputs. All outputs except stdout/stderr will be deleted.
74
static void disable_outputs();
75
76
// Get output index by name. Returns SIZE_MAX if output not found.
77
static size_t find_output(const char* name);
78
79
// Configure output (add or update existing configuration) to log on tag-level combination using specified decorators.
80
static void configure_output(size_t idx, const LogSelectionList& tag_level_expression, const LogDecorators& decorators);
81
82
// This should be called after any configuration change while still holding ConfigurationLock
83
static void notify_update_listeners();
84
85
// Respectively describe the built-in and runtime dependent portions of the configuration.
86
static void describe_available(outputStream* out);
87
static void describe_current_configuration(outputStream* out);
88
89
90
public:
91
// Initialization and finalization of log configuration, to be run at vm startup and shutdown respectively.
92
static void initialize(jlong vm_start_time);
93
static void finalize();
94
95
// Perform necessary post-initialization after VM startup. Enables reconfiguration of logging.
96
static void post_initialize();
97
98
// Disable all logging, equivalent to -Xlog:disable.
99
static void disable_logging();
100
101
// Configures logging on stdout for the given tags and level combination.
102
// Intended for mappings between -XX: flags and Unified Logging configuration.
103
// If exact_match is true, only tagsets with precisely the specified tags will be configured
104
// (exact_match=false is the same as "-Xlog:<tags>*=<level>", and exact_match=true is "-Xlog:<tags>=<level>").
105
// Tags should be specified using the LOG_TAGS macro, e.g.
106
// LogConfiguration::configure_stdout(LogLevel::<level>, <true/false>, LOG_TAGS(<tags>));
107
static void configure_stdout(LogLevelType level, int exact_match, ...);
108
109
// Parse command line configuration. Parameter 'opts' is the string immediately following the -Xlog: argument ("gc" for -Xlog:gc).
110
static bool parse_command_line_arguments(const char* opts = "all");
111
112
// Parse separated configuration arguments (from JCmd/MBean and command line).
113
static bool parse_log_arguments(const char* outputstr,
114
const char* what,
115
const char* decoratorstr,
116
const char* output_options,
117
outputStream* errstream);
118
119
// Prints log configuration to outputStream, used by JCmd/MBean.
120
static void describe(outputStream* out);
121
122
// Prints usage help for command line log configuration.
123
static void print_command_line_help(outputStream* out);
124
125
// Rotates all LogOutput
126
static void rotate_all_outputs();
127
128
static bool is_async_mode() { return _async_mode; }
129
static void set_async_mode(bool value) {
130
_async_mode = value;
131
}
132
};
133
134
#endif // SHARE_LOGGING_LOGCONFIGURATION_HPP
135
136