author | ihse |
Mon, 26 Nov 2018 14:18:22 +0100 | |
branch | ihse-manpages-branch |
changeset 57043 | 23d7457ca4c6 |
parent 49188 | e9ba8b40ca6f |
child 53122 | 883a1a80a6dc |
permissions | -rw-r--r-- |
33097 | 1 |
/* |
49015 | 2 |
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. |
33097 | 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 |
#include "precompiled.hpp" |
|
47765
b7c7428eaab9
8189610: Reconcile jvm.h and all jvm_md.h between java.base and hotspot
coleenp
parents:
47216
diff
changeset
|
25 |
#include "jvm.h" |
33097 | 26 |
#include "logging/log.hpp" |
27 |
#include "logging/logConfiguration.hpp" |
|
28 |
#include "logging/logDecorations.hpp" |
|
29 |
#include "logging/logDecorators.hpp" |
|
30 |
#include "logging/logDiagnosticCommand.hpp" |
|
31 |
#include "logging/logFileOutput.hpp" |
|
32 |
#include "logging/logOutput.hpp" |
|
49016
ea85eed8b012
8196783: Refactor LogTagLevelExpression into separate classes
mlarsson
parents:
49015
diff
changeset
|
33 |
#include "logging/logSelectionList.hpp" |
38292
73a0be9b2f47
8146948: Enable listing of LogTagSets and add support for LogTagSet descriptions
mlarsson
parents:
38195
diff
changeset
|
34 |
#include "logging/logStream.hpp" |
33097 | 35 |
#include "logging/logTagSet.hpp" |
36 |
#include "memory/allocation.inline.hpp" |
|
37 |
#include "memory/resourceArea.hpp" |
|
38 |
#include "runtime/os.inline.hpp" |
|
35228
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
39 |
#include "runtime/semaphore.hpp" |
33097 | 40 |
#include "utilities/globalDefinitions.hpp" |
41 |
||
42 |
LogOutput** LogConfiguration::_outputs = NULL; |
|
43 |
size_t LogConfiguration::_n_outputs = 0; |
|
44 |
||
37108
fe800ec86077
8151264: Add a notification mechanism for UL configuration changes.
rehn
parents:
36174
diff
changeset
|
45 |
LogConfiguration::UpdateListenerFunction* LogConfiguration::_listener_callbacks = NULL; |
fe800ec86077
8151264: Add a notification mechanism for UL configuration changes.
rehn
parents:
36174
diff
changeset
|
46 |
size_t LogConfiguration::_n_listener_callbacks = 0; |
fe800ec86077
8151264: Add a notification mechanism for UL configuration changes.
rehn
parents:
36174
diff
changeset
|
47 |
|
40902
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
48 |
// LogFileOutput is the default type of output, its type prefix should be used if no type was specified |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
49 |
static const char* implicit_output_prefix = LogFileOutput::Prefix; |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
50 |
|
35228
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
51 |
// Stack object to take the lock for configuring the logging. |
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
52 |
// Should only be held during the critical parts of the configuration |
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
53 |
// (when calling configure_output or reading/modifying the outputs array). |
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
54 |
// Thread must never block when holding this lock. |
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
55 |
class ConfigurationLock : public StackObj { |
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
56 |
private: |
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
57 |
// Semaphore used as lock |
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
58 |
static Semaphore _semaphore; |
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
59 |
debug_only(static intx _locking_thread_id;) |
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
60 |
public: |
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
61 |
ConfigurationLock() { |
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
62 |
_semaphore.wait(); |
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
63 |
debug_only(_locking_thread_id = os::current_thread_id()); |
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
64 |
} |
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
65 |
~ConfigurationLock() { |
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
66 |
debug_only(_locking_thread_id = -1); |
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
67 |
_semaphore.signal(); |
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
68 |
} |
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
69 |
debug_only(static bool current_thread_has_lock();) |
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
70 |
}; |
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
71 |
|
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
72 |
Semaphore ConfigurationLock::_semaphore(1); |
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
73 |
#ifdef ASSERT |
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
74 |
intx ConfigurationLock::_locking_thread_id = -1; |
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
75 |
bool ConfigurationLock::current_thread_has_lock() { |
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
76 |
return _locking_thread_id == os::current_thread_id(); |
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
77 |
} |
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
78 |
#endif |
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
79 |
|
33097 | 80 |
void LogConfiguration::post_initialize() { |
49181
fde9b3c56de4
8153945: Track if log configuration has changed during runtime
mlarsson
parents:
49180
diff
changeset
|
81 |
// Reset the reconfigured status of all outputs |
fde9b3c56de4
8153945: Track if log configuration has changed during runtime
mlarsson
parents:
49180
diff
changeset
|
82 |
for (size_t i = 0; i < _n_outputs; i++) { |
fde9b3c56de4
8153945: Track if log configuration has changed during runtime
mlarsson
parents:
49180
diff
changeset
|
83 |
_outputs[i]->_reconfigured = false; |
fde9b3c56de4
8153945: Track if log configuration has changed during runtime
mlarsson
parents:
49180
diff
changeset
|
84 |
} |
fde9b3c56de4
8153945: Track if log configuration has changed during runtime
mlarsson
parents:
49180
diff
changeset
|
85 |
|
33097 | 86 |
LogDiagnosticCommand::registerCommand(); |
37242 | 87 |
Log(logging) log; |
38292
73a0be9b2f47
8146948: Enable listing of LogTagSets and add support for LogTagSet descriptions
mlarsson
parents:
38195
diff
changeset
|
88 |
if (log.is_info()) { |
73a0be9b2f47
8146948: Enable listing of LogTagSets and add support for LogTagSet descriptions
mlarsson
parents:
38195
diff
changeset
|
89 |
log.info("Log configuration fully initialized."); |
73a0be9b2f47
8146948: Enable listing of LogTagSets and add support for LogTagSet descriptions
mlarsson
parents:
38195
diff
changeset
|
90 |
log_develop_info(logging)("Develop logging is available."); |
49180
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
91 |
|
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
92 |
LogStream info_stream(log.info()); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
93 |
describe_available(&info_stream); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
94 |
|
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
95 |
LogStream debug_stream(log.debug()); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
96 |
LogTagSet::list_all_tagsets(&debug_stream); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
97 |
|
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
98 |
ConfigurationLock cl; |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
99 |
describe_current_configuration(&info_stream); |
33097 | 100 |
} |
101 |
} |
|
102 |
||
103 |
void LogConfiguration::initialize(jlong vm_start_time) { |
|
104 |
LogFileOutput::set_file_name_parameters(vm_start_time); |
|
36174 | 105 |
LogDecorations::initialize(vm_start_time); |
33097 | 106 |
assert(_outputs == NULL, "Should not initialize _outputs before this function, initialize called twice?"); |
107 |
_outputs = NEW_C_HEAP_ARRAY(LogOutput*, 2, mtLogging); |
|
42067
34b99c8faa51
8146009: "pure virtual method called" with using new GC logging mechanism
mlarsson
parents:
40924
diff
changeset
|
108 |
_outputs[0] = &StdoutLog; |
34b99c8faa51
8146009: "pure virtual method called" with using new GC logging mechanism
mlarsson
parents:
40924
diff
changeset
|
109 |
_outputs[1] = &StderrLog; |
33097 | 110 |
_n_outputs = 2; |
111 |
} |
|
112 |
||
113 |
void LogConfiguration::finalize() { |
|
42067
34b99c8faa51
8146009: "pure virtual method called" with using new GC logging mechanism
mlarsson
parents:
40924
diff
changeset
|
114 |
for (size_t i = _n_outputs; i > 0; i--) { |
34b99c8faa51
8146009: "pure virtual method called" with using new GC logging mechanism
mlarsson
parents:
40924
diff
changeset
|
115 |
disable_output(i - 1); |
33097 | 116 |
} |
117 |
FREE_C_HEAP_ARRAY(LogOutput*, _outputs); |
|
118 |
} |
|
119 |
||
40902
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
120 |
// Normalizes the given LogOutput name to type=name form. |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
121 |
// For example, foo, "foo", file="foo", will all be normalized to file=foo (no quotes, prefixed). |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
122 |
static bool normalize_output_name(const char* full_name, char* buffer, size_t len, outputStream* errstream) { |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
123 |
const char* start_quote = strchr(full_name, '"'); |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
124 |
const char* equals = strchr(full_name, '='); |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
125 |
const bool quoted = start_quote != NULL; |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
126 |
const bool is_stdout_or_stderr = (strcmp(full_name, "stdout") == 0 || strcmp(full_name, "stderr") == 0); |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
127 |
|
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
128 |
// ignore equals sign within quotes |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
129 |
if (quoted && equals > start_quote) { |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
130 |
equals = NULL; |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
131 |
} |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
132 |
|
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
133 |
const char* prefix = ""; |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
134 |
size_t prefix_len = 0; |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
135 |
const char* name = full_name; |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
136 |
if (equals != NULL) { |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
137 |
// split on equals sign |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
138 |
name = equals + 1; |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
139 |
prefix = full_name; |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
140 |
prefix_len = equals - full_name + 1; |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
141 |
} else if (!is_stdout_or_stderr) { |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
142 |
prefix = implicit_output_prefix; |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
143 |
prefix_len = strlen(prefix); |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
144 |
} |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
145 |
size_t name_len = strlen(name); |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
146 |
|
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
147 |
if (quoted) { |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
148 |
const char* end_quote = strchr(start_quote + 1, '"'); |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
149 |
if (end_quote == NULL) { |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
150 |
errstream->print_cr("Output name has opening quote but is missing a terminating quote."); |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
151 |
return false; |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
152 |
} |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
153 |
if (start_quote != name || end_quote[1] != '\0') { |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
154 |
errstream->print_cr("Output name can not be partially quoted." |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
155 |
" Either surround the whole name with quotation marks," |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
156 |
" or do not use quotation marks at all."); |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
157 |
return false; |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
158 |
} |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
159 |
// strip start and end quote |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
160 |
name++; |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
161 |
name_len -= 2; |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
162 |
} |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
163 |
|
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
164 |
int ret = jio_snprintf(buffer, len, "%.*s%.*s", prefix_len, prefix, name_len, name); |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
165 |
assert(ret > 0, "buffer issue"); |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
166 |
return true; |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
167 |
} |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
168 |
|
33097 | 169 |
size_t LogConfiguration::find_output(const char* name) { |
170 |
for (size_t i = 0; i < _n_outputs; i++) { |
|
171 |
if (strcmp(_outputs[i]->name(), name) == 0) { |
|
172 |
return i; |
|
173 |
} |
|
174 |
} |
|
175 |
return SIZE_MAX; |
|
176 |
} |
|
177 |
||
40902
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
178 |
LogOutput* LogConfiguration::new_output(const char* name, |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
179 |
const char* options, |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
180 |
outputStream* errstream) { |
33097 | 181 |
LogOutput* output; |
40902
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
182 |
if (strncmp(name, LogFileOutput::Prefix, strlen(LogFileOutput::Prefix)) == 0) { |
33097 | 183 |
output = new LogFileOutput(name); |
184 |
} else { |
|
40902
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
185 |
errstream->print_cr("Unsupported log output type: %s", name); |
33097 | 186 |
return NULL; |
187 |
} |
|
188 |
||
37465
1d5551f466ee
8146879: Add option for handling existing log files in UL
mlarsson
parents:
37242
diff
changeset
|
189 |
bool success = output->initialize(options, errstream); |
33097 | 190 |
if (!success) { |
35229
b8d78ee728b2
8144220: UL does not support full path names for log files on windows
mlarsson
parents:
35228
diff
changeset
|
191 |
errstream->print_cr("Initialization of output '%s' using options '%s' failed.", name, options); |
33097 | 192 |
delete output; |
193 |
return NULL; |
|
194 |
} |
|
195 |
return output; |
|
196 |
} |
|
197 |
||
198 |
size_t LogConfiguration::add_output(LogOutput* output) { |
|
199 |
size_t idx = _n_outputs++; |
|
200 |
_outputs = REALLOC_C_HEAP_ARRAY(LogOutput*, _outputs, _n_outputs, mtLogging); |
|
201 |
_outputs[idx] = output; |
|
202 |
return idx; |
|
203 |
} |
|
204 |
||
205 |
void LogConfiguration::delete_output(size_t idx) { |
|
206 |
assert(idx > 1 && idx < _n_outputs, |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
33097
diff
changeset
|
207 |
"idx must be in range 1 < idx < _n_outputs, but idx = " SIZE_FORMAT |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
33097
diff
changeset
|
208 |
" and _n_outputs = " SIZE_FORMAT, idx, _n_outputs); |
33097 | 209 |
LogOutput* output = _outputs[idx]; |
210 |
// Swap places with the last output and shrink the array |
|
211 |
_outputs[idx] = _outputs[--_n_outputs]; |
|
212 |
_outputs = REALLOC_C_HEAP_ARRAY(LogOutput*, _outputs, _n_outputs, mtLogging); |
|
213 |
delete output; |
|
214 |
} |
|
215 |
||
49016
ea85eed8b012
8196783: Refactor LogTagLevelExpression into separate classes
mlarsson
parents:
49015
diff
changeset
|
216 |
void LogConfiguration::configure_output(size_t idx, const LogSelectionList& selections, const LogDecorators& decorators) { |
35228
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
217 |
assert(ConfigurationLock::current_thread_has_lock(), "Must hold configuration lock to call this function."); |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
33097
diff
changeset
|
218 |
assert(idx < _n_outputs, "Invalid index, idx = " SIZE_FORMAT " and _n_outputs = " SIZE_FORMAT, idx, _n_outputs); |
33097 | 219 |
LogOutput* output = _outputs[idx]; |
34316
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
220 |
|
49181
fde9b3c56de4
8153945: Track if log configuration has changed during runtime
mlarsson
parents:
49180
diff
changeset
|
221 |
output->_reconfigured = true; |
fde9b3c56de4
8153945: Track if log configuration has changed during runtime
mlarsson
parents:
49180
diff
changeset
|
222 |
|
49188
e9ba8b40ca6f
8168722: Unified Logging configuration output needs simplifying
mlarsson
parents:
49183
diff
changeset
|
223 |
size_t on_level[LogLevel::Count] = {0}; |
34316
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
224 |
|
33097 | 225 |
bool enabled = false; |
226 |
for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) { |
|
49016
ea85eed8b012
8196783: Refactor LogTagLevelExpression into separate classes
mlarsson
parents:
49015
diff
changeset
|
227 |
LogLevelType level = selections.level_for(*ts); |
34316
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
228 |
|
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
229 |
// Ignore tagsets that do not, and will not log on the output |
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
230 |
if (!ts->has_output(output) && (level == LogLevel::NotMentioned || level == LogLevel::Off)) { |
49188
e9ba8b40ca6f
8168722: Unified Logging configuration output needs simplifying
mlarsson
parents:
49183
diff
changeset
|
231 |
on_level[LogLevel::Off]++; |
34316
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
232 |
continue; |
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
233 |
} |
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
234 |
|
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
235 |
// Update decorators before adding/updating output level, |
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
236 |
// so that the tagset will have the necessary decorators when requiring them. |
33097 | 237 |
if (level != LogLevel::Off) { |
34316
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
238 |
ts->update_decorators(decorators); |
33097 | 239 |
} |
34316
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
240 |
|
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
241 |
// Set the new level, if it changed |
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
242 |
if (level != LogLevel::NotMentioned) { |
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
243 |
ts->set_output_level(output, level); |
49188
e9ba8b40ca6f
8168722: Unified Logging configuration output needs simplifying
mlarsson
parents:
49183
diff
changeset
|
244 |
} else { |
e9ba8b40ca6f
8168722: Unified Logging configuration output needs simplifying
mlarsson
parents:
49183
diff
changeset
|
245 |
// Look up the previously set level for this output on this tagset |
e9ba8b40ca6f
8168722: Unified Logging configuration output needs simplifying
mlarsson
parents:
49183
diff
changeset
|
246 |
level = ts->level_for(output); |
34316
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
247 |
} |
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
248 |
|
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
249 |
if (level != LogLevel::Off) { |
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
250 |
// Keep track of whether or not the output is ever used by some tagset |
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
251 |
enabled = true; |
49188
e9ba8b40ca6f
8168722: Unified Logging configuration output needs simplifying
mlarsson
parents:
49183
diff
changeset
|
252 |
} |
34316
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
253 |
|
49188
e9ba8b40ca6f
8168722: Unified Logging configuration output needs simplifying
mlarsson
parents:
49183
diff
changeset
|
254 |
// Track of the number of tag sets on each level |
e9ba8b40ca6f
8168722: Unified Logging configuration output needs simplifying
mlarsson
parents:
49183
diff
changeset
|
255 |
on_level[level]++; |
33097 | 256 |
} |
257 |
||
34316
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
258 |
// It is now safe to set the new decorators for the actual output |
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
259 |
output->set_decorators(decorators); |
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
260 |
|
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
261 |
// Update the decorators on all tagsets to get rid of unused decorators |
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
262 |
for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) { |
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
263 |
ts->update_decorators(); |
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
264 |
} |
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
265 |
|
49188
e9ba8b40ca6f
8168722: Unified Logging configuration output needs simplifying
mlarsson
parents:
49183
diff
changeset
|
266 |
if (!enabled && idx > 1) { |
e9ba8b40ca6f
8168722: Unified Logging configuration output needs simplifying
mlarsson
parents:
49183
diff
changeset
|
267 |
// Output is unused and should be removed, unless it is stdout/stderr (idx < 2) |
33097 | 268 |
delete_output(idx); |
49188
e9ba8b40ca6f
8168722: Unified Logging configuration output needs simplifying
mlarsson
parents:
49183
diff
changeset
|
269 |
return; |
33097 | 270 |
} |
49188
e9ba8b40ca6f
8168722: Unified Logging configuration output needs simplifying
mlarsson
parents:
49183
diff
changeset
|
271 |
|
e9ba8b40ca6f
8168722: Unified Logging configuration output needs simplifying
mlarsson
parents:
49183
diff
changeset
|
272 |
output->update_config_string(on_level); |
e9ba8b40ca6f
8168722: Unified Logging configuration output needs simplifying
mlarsson
parents:
49183
diff
changeset
|
273 |
assert(strlen(output->config_string()) > 0, "should always have a config description"); |
33097 | 274 |
} |
275 |
||
276 |
void LogConfiguration::disable_output(size_t idx) { |
|
40885 | 277 |
assert(idx < _n_outputs, "invalid index: " SIZE_FORMAT " (_n_outputs: " SIZE_FORMAT ")", idx, _n_outputs); |
33097 | 278 |
LogOutput* out = _outputs[idx]; |
279 |
||
280 |
// Remove the output from all tagsets. |
|
281 |
for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) { |
|
282 |
ts->set_output_level(out, LogLevel::Off); |
|
34316
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
283 |
ts->update_decorators(); |
33097 | 284 |
} |
285 |
||
42067
34b99c8faa51
8146009: "pure virtual method called" with using new GC logging mechanism
mlarsson
parents:
40924
diff
changeset
|
286 |
// Delete the output unless stdout or stderr (idx 0 or 1) |
34b99c8faa51
8146009: "pure virtual method called" with using new GC logging mechanism
mlarsson
parents:
40924
diff
changeset
|
287 |
if (idx > 1) { |
40885 | 288 |
delete_output(idx); |
33097 | 289 |
} else { |
290 |
out->set_config_string("all=off"); |
|
291 |
} |
|
292 |
} |
|
293 |
||
294 |
void LogConfiguration::disable_logging() { |
|
35228
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
295 |
ConfigurationLock cl; |
40885 | 296 |
for (size_t i = _n_outputs; i > 0; i--) { |
297 |
disable_output(i - 1); |
|
33097 | 298 |
} |
37108
fe800ec86077
8151264: Add a notification mechanism for UL configuration changes.
rehn
parents:
36174
diff
changeset
|
299 |
notify_update_listeners(); |
33097 | 300 |
} |
301 |
||
48824 | 302 |
void LogConfiguration::configure_stdout(LogLevelType level, int exact_match, ...) { |
34316
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
303 |
size_t i; |
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
304 |
va_list ap; |
49016
ea85eed8b012
8196783: Refactor LogTagLevelExpression into separate classes
mlarsson
parents:
49015
diff
changeset
|
305 |
LogTagType tags[LogTag::MaxTags]; |
34316
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
306 |
va_start(ap, exact_match); |
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
307 |
for (i = 0; i < LogTag::MaxTags; i++) { |
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
308 |
LogTagType tag = static_cast<LogTagType>(va_arg(ap, int)); |
49016
ea85eed8b012
8196783: Refactor LogTagLevelExpression into separate classes
mlarsson
parents:
49015
diff
changeset
|
309 |
tags[i] = tag; |
34316
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
310 |
if (tag == LogTag::__NO_TAG) { |
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
311 |
assert(i > 0, "Must specify at least one tag!"); |
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
312 |
break; |
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
313 |
} |
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
314 |
} |
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
315 |
assert(i < LogTag::MaxTags || static_cast<LogTagType>(va_arg(ap, int)) == LogTag::__NO_TAG, |
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
316 |
"Too many tags specified! Can only have up to " SIZE_FORMAT " tags in a tag set.", LogTag::MaxTags); |
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
317 |
va_end(ap); |
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
318 |
|
49016
ea85eed8b012
8196783: Refactor LogTagLevelExpression into separate classes
mlarsson
parents:
49015
diff
changeset
|
319 |
LogSelection selection(tags, !exact_match, level); |
ea85eed8b012
8196783: Refactor LogTagLevelExpression into separate classes
mlarsson
parents:
49015
diff
changeset
|
320 |
assert(selection.tag_sets_selected() > 0, |
ea85eed8b012
8196783: Refactor LogTagLevelExpression into separate classes
mlarsson
parents:
49015
diff
changeset
|
321 |
"configure_stdout() called with invalid/non-existing log selection"); |
ea85eed8b012
8196783: Refactor LogTagLevelExpression into separate classes
mlarsson
parents:
49015
diff
changeset
|
322 |
LogSelectionList list(selection); |
34316
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
323 |
|
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
324 |
// Apply configuration to stdout (output #0), with the same decorators as before. |
35228
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
325 |
ConfigurationLock cl; |
49016
ea85eed8b012
8196783: Refactor LogTagLevelExpression into separate classes
mlarsson
parents:
49015
diff
changeset
|
326 |
configure_output(0, list, _outputs[0]->decorators()); |
37108
fe800ec86077
8151264: Add a notification mechanism for UL configuration changes.
rehn
parents:
36174
diff
changeset
|
327 |
notify_update_listeners(); |
34316
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
328 |
} |
4d876653d940
8142952: Unified Logging framework does not allow multiple -Xlog: arguments.
mlarsson
parents:
34252
diff
changeset
|
329 |
|
33097 | 330 |
bool LogConfiguration::parse_command_line_arguments(const char* opts) { |
331 |
char* copy = os::strdup_check_oom(opts, mtLogging); |
|
332 |
||
333 |
// Split the option string to its colon separated components. |
|
35229
b8d78ee728b2
8144220: UL does not support full path names for log files on windows
mlarsson
parents:
35228
diff
changeset
|
334 |
char* str = copy; |
b8d78ee728b2
8144220: UL does not support full path names for log files on windows
mlarsson
parents:
35228
diff
changeset
|
335 |
char* substrings[4] = {0}; |
b8d78ee728b2
8144220: UL does not support full path names for log files on windows
mlarsson
parents:
35228
diff
changeset
|
336 |
for (int i = 0 ; i < 4; i++) { |
b8d78ee728b2
8144220: UL does not support full path names for log files on windows
mlarsson
parents:
35228
diff
changeset
|
337 |
substrings[i] = str; |
33097 | 338 |
|
35229
b8d78ee728b2
8144220: UL does not support full path names for log files on windows
mlarsson
parents:
35228
diff
changeset
|
339 |
// Find the next colon or quote |
b8d78ee728b2
8144220: UL does not support full path names for log files on windows
mlarsson
parents:
35228
diff
changeset
|
340 |
char* next = strpbrk(str, ":\""); |
b8d78ee728b2
8144220: UL does not support full path names for log files on windows
mlarsson
parents:
35228
diff
changeset
|
341 |
while (next != NULL && *next == '"') { |
b8d78ee728b2
8144220: UL does not support full path names for log files on windows
mlarsson
parents:
35228
diff
changeset
|
342 |
char* end_quote = strchr(next + 1, '"'); |
b8d78ee728b2
8144220: UL does not support full path names for log files on windows
mlarsson
parents:
35228
diff
changeset
|
343 |
if (end_quote == NULL) { |
b8d78ee728b2
8144220: UL does not support full path names for log files on windows
mlarsson
parents:
35228
diff
changeset
|
344 |
log_error(logging)("Missing terminating quote in -Xlog option '%s'", str); |
b8d78ee728b2
8144220: UL does not support full path names for log files on windows
mlarsson
parents:
35228
diff
changeset
|
345 |
os::free(copy); |
b8d78ee728b2
8144220: UL does not support full path names for log files on windows
mlarsson
parents:
35228
diff
changeset
|
346 |
return false; |
33097 | 347 |
} |
35229
b8d78ee728b2
8144220: UL does not support full path names for log files on windows
mlarsson
parents:
35228
diff
changeset
|
348 |
// Keep searching after the quoted substring |
b8d78ee728b2
8144220: UL does not support full path names for log files on windows
mlarsson
parents:
35228
diff
changeset
|
349 |
next = strpbrk(end_quote + 1, ":\""); |
b8d78ee728b2
8144220: UL does not support full path names for log files on windows
mlarsson
parents:
35228
diff
changeset
|
350 |
} |
b8d78ee728b2
8144220: UL does not support full path names for log files on windows
mlarsson
parents:
35228
diff
changeset
|
351 |
|
b8d78ee728b2
8144220: UL does not support full path names for log files on windows
mlarsson
parents:
35228
diff
changeset
|
352 |
if (next != NULL) { |
b8d78ee728b2
8144220: UL does not support full path names for log files on windows
mlarsson
parents:
35228
diff
changeset
|
353 |
*next = '\0'; |
b8d78ee728b2
8144220: UL does not support full path names for log files on windows
mlarsson
parents:
35228
diff
changeset
|
354 |
str = next + 1; |
b8d78ee728b2
8144220: UL does not support full path names for log files on windows
mlarsson
parents:
35228
diff
changeset
|
355 |
} else { |
b8d78ee728b2
8144220: UL does not support full path names for log files on windows
mlarsson
parents:
35228
diff
changeset
|
356 |
break; |
33097 | 357 |
} |
358 |
} |
|
359 |
||
35229
b8d78ee728b2
8144220: UL does not support full path names for log files on windows
mlarsson
parents:
35228
diff
changeset
|
360 |
// Parse and apply the separated configuration options |
b8d78ee728b2
8144220: UL does not support full path names for log files on windows
mlarsson
parents:
35228
diff
changeset
|
361 |
char* what = substrings[0]; |
b8d78ee728b2
8144220: UL does not support full path names for log files on windows
mlarsson
parents:
35228
diff
changeset
|
362 |
char* output = substrings[1]; |
b8d78ee728b2
8144220: UL does not support full path names for log files on windows
mlarsson
parents:
35228
diff
changeset
|
363 |
char* decorators = substrings[2]; |
b8d78ee728b2
8144220: UL does not support full path names for log files on windows
mlarsson
parents:
35228
diff
changeset
|
364 |
char* output_options = substrings[3]; |
33097 | 365 |
char errbuf[512]; |
366 |
stringStream ss(errbuf, sizeof(errbuf)); |
|
35229
b8d78ee728b2
8144220: UL does not support full path names for log files on windows
mlarsson
parents:
35228
diff
changeset
|
367 |
bool success = parse_log_arguments(output, what, decorators, output_options, &ss); |
40884
0e28c526f5d3
8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents:
39707
diff
changeset
|
368 |
|
0e28c526f5d3
8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents:
39707
diff
changeset
|
369 |
if (ss.size() > 0) { |
0e28c526f5d3
8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents:
39707
diff
changeset
|
370 |
// If it failed, log the error. If it didn't fail, but something was written |
0e28c526f5d3
8150894: Unused -Xlog tag sequences are silently ignored.
mlarsson
parents:
39707
diff
changeset
|
371 |
// to the stream, log it as a warning. |
49180
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
372 |
LogLevelType level = success ? LogLevel::Warning : LogLevel::Error; |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
373 |
|
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
374 |
Log(logging) log; |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
375 |
char* start = errbuf; |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
376 |
char* end = strchr(start, '\n'); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
377 |
assert(end != NULL, "line must end with newline '%s'", start); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
378 |
do { |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
379 |
assert(start < errbuf + sizeof(errbuf) && |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
380 |
end < errbuf + sizeof(errbuf), |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
381 |
"buffer overflow"); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
382 |
*end = '\0'; |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
383 |
log.write(level, "%s", start); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
384 |
start = end + 1; |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
385 |
end = strchr(start, '\n'); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
386 |
assert(end != NULL || *start == '\0', "line must end with newline '%s'", start); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
387 |
} while (end != NULL); |
33097 | 388 |
} |
389 |
||
390 |
os::free(copy); |
|
391 |
return success; |
|
392 |
} |
|
393 |
||
394 |
bool LogConfiguration::parse_log_arguments(const char* outputstr, |
|
49016
ea85eed8b012
8196783: Refactor LogTagLevelExpression into separate classes
mlarsson
parents:
49015
diff
changeset
|
395 |
const char* selectionstr, |
33097 | 396 |
const char* decoratorstr, |
397 |
const char* output_options, |
|
398 |
outputStream* errstream) { |
|
40924 | 399 |
assert(errstream != NULL, "errstream can not be NULL"); |
33097 | 400 |
if (outputstr == NULL || strlen(outputstr) == 0) { |
401 |
outputstr = "stdout"; |
|
402 |
} |
|
403 |
||
49016
ea85eed8b012
8196783: Refactor LogTagLevelExpression into separate classes
mlarsson
parents:
49015
diff
changeset
|
404 |
LogSelectionList selections; |
ea85eed8b012
8196783: Refactor LogTagLevelExpression into separate classes
mlarsson
parents:
49015
diff
changeset
|
405 |
if (!selections.parse(selectionstr, errstream)) { |
35228
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
406 |
return false; |
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
407 |
} |
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
408 |
|
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
409 |
LogDecorators decorators; |
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
410 |
if (!decorators.parse(decoratorstr, errstream)) { |
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
411 |
return false; |
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
412 |
} |
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
413 |
|
e7bbfb90fd31
8145083: Use semaphore instead of mutex for synchronization of Unified Logging configuration
mlarsson
parents:
34637
diff
changeset
|
414 |
ConfigurationLock cl; |
33097 | 415 |
size_t idx; |
40902
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
416 |
if (outputstr[0] == '#') { // Output specified using index |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
417 |
int ret = sscanf(outputstr + 1, SIZE_FORMAT, &idx); |
33097 | 418 |
if (ret != 1 || idx >= _n_outputs) { |
419 |
errstream->print_cr("Invalid output index '%s'", outputstr); |
|
420 |
return false; |
|
421 |
} |
|
40902
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
422 |
} else { // Output specified using name |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
423 |
// Normalize the name, stripping quotes and ensures it includes type prefix |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
424 |
size_t len = strlen(outputstr) + strlen(implicit_output_prefix) + 1; |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
425 |
char* normalized = NEW_C_HEAP_ARRAY(char, len, mtLogging); |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
426 |
if (!normalize_output_name(outputstr, normalized, len, errstream)) { |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
427 |
return false; |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
428 |
} |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
429 |
|
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
430 |
idx = find_output(normalized); |
33097 | 431 |
if (idx == SIZE_MAX) { |
40902
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
432 |
// Attempt to create and add the output |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
433 |
LogOutput* output = new_output(normalized, output_options, errstream); |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
434 |
if (output != NULL) { |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
435 |
idx = add_output(output); |
33097 | 436 |
} |
437 |
} else if (output_options != NULL && strlen(output_options) > 0) { |
|
438 |
errstream->print_cr("Output options for existing outputs are ignored."); |
|
439 |
} |
|
40902
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
440 |
|
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
441 |
FREE_C_HEAP_ARRAY(char, normalized); |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
442 |
if (idx == SIZE_MAX) { |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
443 |
return false; |
395e1f3ec886
8157948: UL allows same log file with multiple file=
mlarsson
parents:
40885
diff
changeset
|
444 |
} |
33097 | 445 |
} |
49016
ea85eed8b012
8196783: Refactor LogTagLevelExpression into separate classes
mlarsson
parents:
49015
diff
changeset
|
446 |
configure_output(idx, selections, decorators); |
37108
fe800ec86077
8151264: Add a notification mechanism for UL configuration changes.
rehn
parents:
36174
diff
changeset
|
447 |
notify_update_listeners(); |
49016
ea85eed8b012
8196783: Refactor LogTagLevelExpression into separate classes
mlarsson
parents:
49015
diff
changeset
|
448 |
selections.verify_selections(errstream); |
33097 | 449 |
return true; |
450 |
} |
|
451 |
||
49181
fde9b3c56de4
8153945: Track if log configuration has changed during runtime
mlarsson
parents:
49180
diff
changeset
|
452 |
void LogConfiguration::describe_available(outputStream* out) { |
33097 | 453 |
out->print("Available log levels:"); |
454 |
for (size_t i = 0; i < LogLevel::Count; i++) { |
|
455 |
out->print("%s %s", (i == 0 ? "" : ","), LogLevel::name(static_cast<LogLevelType>(i))); |
|
456 |
} |
|
457 |
out->cr(); |
|
458 |
||
459 |
out->print("Available log decorators:"); |
|
460 |
for (size_t i = 0; i < LogDecorators::Count; i++) { |
|
461 |
LogDecorators::Decorator d = static_cast<LogDecorators::Decorator>(i); |
|
462 |
out->print("%s %s (%s)", (i == 0 ? "" : ","), LogDecorators::name(d), LogDecorators::abbreviation(d)); |
|
463 |
} |
|
464 |
out->cr(); |
|
465 |
||
466 |
out->print("Available log tags:"); |
|
49015 | 467 |
LogTag::list_tags(out); |
33097 | 468 |
|
38292
73a0be9b2f47
8146948: Enable listing of LogTagSets and add support for LogTagSet descriptions
mlarsson
parents:
38195
diff
changeset
|
469 |
LogTagSet::describe_tagsets(out); |
37994
1a816b464178
8151526: Print -Xlog configuration in the hs_err_pid file
mockner
parents:
37465
diff
changeset
|
470 |
} |
1a816b464178
8151526: Print -Xlog configuration in the hs_err_pid file
mockner
parents:
37465
diff
changeset
|
471 |
|
49181
fde9b3c56de4
8153945: Track if log configuration has changed during runtime
mlarsson
parents:
49180
diff
changeset
|
472 |
void LogConfiguration::describe_current_configuration(outputStream* out) { |
33097 | 473 |
out->print_cr("Log output configuration:"); |
474 |
for (size_t i = 0; i < _n_outputs; i++) { |
|
49180
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
475 |
out->print(" #" SIZE_FORMAT ": ", i); |
39707 | 476 |
_outputs[i]->describe(out); |
49181
fde9b3c56de4
8153945: Track if log configuration has changed during runtime
mlarsson
parents:
49180
diff
changeset
|
477 |
if (_outputs[i]->is_reconfigured()) { |
fde9b3c56de4
8153945: Track if log configuration has changed during runtime
mlarsson
parents:
49180
diff
changeset
|
478 |
out->print(" (reconfigured)"); |
fde9b3c56de4
8153945: Track if log configuration has changed during runtime
mlarsson
parents:
49180
diff
changeset
|
479 |
} |
33097 | 480 |
out->cr(); |
481 |
} |
|
482 |
} |
|
483 |
||
37994
1a816b464178
8151526: Print -Xlog configuration in the hs_err_pid file
mockner
parents:
37465
diff
changeset
|
484 |
void LogConfiguration::describe(outputStream* out) { |
1a816b464178
8151526: Print -Xlog configuration in the hs_err_pid file
mockner
parents:
37465
diff
changeset
|
485 |
describe_available(out); |
1a816b464178
8151526: Print -Xlog configuration in the hs_err_pid file
mockner
parents:
37465
diff
changeset
|
486 |
ConfigurationLock cl; |
1a816b464178
8151526: Print -Xlog configuration in the hs_err_pid file
mockner
parents:
37465
diff
changeset
|
487 |
describe_current_configuration(out); |
1a816b464178
8151526: Print -Xlog configuration in the hs_err_pid file
mockner
parents:
37465
diff
changeset
|
488 |
} |
1a816b464178
8151526: Print -Xlog configuration in the hs_err_pid file
mockner
parents:
37465
diff
changeset
|
489 |
|
49180
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
490 |
void LogConfiguration::print_command_line_help(outputStream* out) { |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
491 |
out->print_cr("-Xlog Usage: -Xlog[:[selections][:[output][:[decorators][:output-options]]]]"); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
492 |
out->print_cr("\t where 'selections' are combinations of tags and levels of the form tag1[+tag2...][*][=level][,...]"); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
493 |
out->print_cr("\t NOTE: Unless wildcard (*) is specified, only log messages tagged with exactly the tags specified will be matched."); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
494 |
out->cr(); |
33097 | 495 |
|
49180
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
496 |
out->print_cr("Available log levels:"); |
33097 | 497 |
for (size_t i = 0; i < LogLevel::Count; i++) { |
49180
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
498 |
out->print("%s %s", (i == 0 ? "" : ","), LogLevel::name(static_cast<LogLevelType>(i))); |
33097 | 499 |
} |
49180
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
500 |
out->cr(); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
501 |
out->cr(); |
33097 | 502 |
|
49180
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
503 |
out->print_cr("Available log decorators: "); |
33097 | 504 |
for (size_t i = 0; i < LogDecorators::Count; i++) { |
505 |
LogDecorators::Decorator d = static_cast<LogDecorators::Decorator>(i); |
|
49180
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
506 |
out->print("%s %s (%s)", (i == 0 ? "" : ","), LogDecorators::name(d), LogDecorators::abbreviation(d)); |
33097 | 507 |
} |
49180
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
508 |
out->cr(); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
509 |
out->print_cr(" Decorators can also be specified as 'none' for no decoration."); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
510 |
out->cr(); |
33097 | 511 |
|
49180
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
512 |
out->print_cr("Available log tags:"); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
513 |
LogTag::list_tags(out); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
514 |
out->print_cr(" Specifying 'all' instead of a tag combination matches all tag combinations."); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
515 |
out->cr(); |
33097 | 516 |
|
49180
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
517 |
LogTagSet::describe_tagsets(out); |
38292
73a0be9b2f47
8146948: Enable listing of LogTagSets and add support for LogTagSet descriptions
mlarsson
parents:
38195
diff
changeset
|
518 |
|
49180
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
519 |
out->print_cr("\nAvailable log outputs:"); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
520 |
out->print_cr(" stdout/stderr"); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
521 |
out->print_cr(" file=<filename>"); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
522 |
out->print_cr(" If the filename contains %%p and/or %%t, they will expand to the JVM's PID and startup timestamp, respectively."); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
523 |
out->print_cr(" Additional output-options for file outputs:"); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
524 |
out->print_cr(" filesize=.. - Target byte size for log rotation (supports K/M/G suffix)." |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
525 |
" If set to 0, log rotation will not trigger automatically," |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
526 |
" but can be performed manually (see the VM.log DCMD)."); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
527 |
out->print_cr(" filecount=.. - Number of files to keep in rotation (not counting the active file)." |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
528 |
" If set to 0, log rotation is disabled." |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
529 |
" This will cause existing log files to be overwritten."); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
530 |
out->cr(); |
33097 | 531 |
|
49180
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
532 |
out->print_cr("Some examples:"); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
533 |
out->print_cr(" -Xlog"); |
49183
268beecd832a
8187066: -Xlog:help "=debug" example is not quite accurate
mlarsson
parents:
49181
diff
changeset
|
534 |
out->print_cr("\t Log all messages up to 'info' level to stdout with 'uptime', 'levels' and 'tags' decorations."); |
49180
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
535 |
out->print_cr("\t (Equivalent to -Xlog:all=info:stdout:uptime,levels,tags)."); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
536 |
out->cr(); |
33097 | 537 |
|
49180
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
538 |
out->print_cr(" -Xlog:gc"); |
49183
268beecd832a
8187066: -Xlog:help "=debug" example is not quite accurate
mlarsson
parents:
49181
diff
changeset
|
539 |
out->print_cr("\t Log messages tagged with 'gc' tag up to 'info' level to stdout, with default decorations."); |
49180
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
540 |
out->cr(); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
541 |
|
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
542 |
out->print_cr(" -Xlog:gc,safepoint"); |
49183
268beecd832a
8187066: -Xlog:help "=debug" example is not quite accurate
mlarsson
parents:
49181
diff
changeset
|
543 |
out->print_cr("\t Log messages tagged either with 'gc' or 'safepoint' tags, both up to 'info' level, to stdout, with default decorations."); |
49180
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
544 |
out->print_cr("\t (Messages tagged with both 'gc' and 'safepoint' will not be logged.)"); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
545 |
out->cr(); |
43417
90c1f522d37e
8170855: Example for -Xlog:help do not contain one with multiple tags
mlarsson
parents:
42067
diff
changeset
|
546 |
|
49180
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
547 |
out->print_cr(" -Xlog:gc+ref=debug"); |
49183
268beecd832a
8187066: -Xlog:help "=debug" example is not quite accurate
mlarsson
parents:
49181
diff
changeset
|
548 |
out->print_cr("\t Log messages tagged with both 'gc' and 'ref' tags, up to 'debug' level, to stdout, with default decorations."); |
49180
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
549 |
out->print_cr("\t (Messages tagged only with one of the two tags will not be logged.)"); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
550 |
out->cr(); |
43417
90c1f522d37e
8170855: Example for -Xlog:help do not contain one with multiple tags
mlarsson
parents:
42067
diff
changeset
|
551 |
|
49180
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
552 |
out->print_cr(" -Xlog:gc=debug:file=gc.txt:none"); |
49183
268beecd832a
8187066: -Xlog:help "=debug" example is not quite accurate
mlarsson
parents:
49181
diff
changeset
|
553 |
out->print_cr("\t Log messages tagged with 'gc' tag up to 'debug' level to file 'gc.txt' with no decorations."); |
49180
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
554 |
out->cr(); |
33097 | 555 |
|
49180
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
556 |
out->print_cr(" -Xlog:gc=trace:file=gctrace.txt:uptimemillis,pids:filecount=5,filesize=1m"); |
49183
268beecd832a
8187066: -Xlog:help "=debug" example is not quite accurate
mlarsson
parents:
49181
diff
changeset
|
557 |
out->print_cr("\t Log messages tagged with 'gc' tag up to 'trace' level to a rotating fileset of 5 files of size 1MB,"); |
49180
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
558 |
out->print_cr("\t using the base name 'gctrace.txt', with 'uptimemillis' and 'pid' decorations."); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
559 |
out->cr(); |
33097 | 560 |
|
49180
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
561 |
out->print_cr(" -Xlog:gc::uptime,tid"); |
49183
268beecd832a
8187066: -Xlog:help "=debug" example is not quite accurate
mlarsson
parents:
49181
diff
changeset
|
562 |
out->print_cr("\t Log messages tagged with 'gc' tag up to 'info' level to output 'stdout', using 'uptime' and 'tid' decorations."); |
49180
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
563 |
out->cr(); |
33097 | 564 |
|
49180
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
565 |
out->print_cr(" -Xlog:gc*=info,safepoint*=off"); |
49183
268beecd832a
8187066: -Xlog:help "=debug" example is not quite accurate
mlarsson
parents:
49181
diff
changeset
|
566 |
out->print_cr("\t Log messages tagged with at least 'gc' up to 'info' level, but turn off logging of messages tagged with 'safepoint'."); |
49180
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
567 |
out->print_cr("\t (Messages tagged with both 'gc' and 'safepoint' will not be logged.)"); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
568 |
out->cr(); |
33097 | 569 |
|
49180
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
570 |
out->print_cr(" -Xlog:disable -Xlog:safepoint=trace:safepointtrace.txt"); |
9637557def32
8190346: improve unified JVM logging help message and warnings
mlarsson
parents:
49016
diff
changeset
|
571 |
out->print_cr("\t Turn off all logging, including warnings and errors,"); |
49183
268beecd832a
8187066: -Xlog:help "=debug" example is not quite accurate
mlarsson
parents:
49181
diff
changeset
|
572 |
out->print_cr("\t and then enable messages tagged with 'safepoint' up to 'trace' level to file 'safepointtrace.txt'."); |
33097 | 573 |
} |
34637
9b9298044d23
8140556: Add force rotation option to VM.log jcmd
ysuenaga
parents:
34316
diff
changeset
|
574 |
|
9b9298044d23
8140556: Add force rotation option to VM.log jcmd
ysuenaga
parents:
34316
diff
changeset
|
575 |
void LogConfiguration::rotate_all_outputs() { |
35230
a528ea8203ec
8145294: TestLogRotation.java triggers a race in the UL framework
mlarsson
parents:
35229
diff
changeset
|
576 |
// Start from index 2 since neither stdout nor stderr can be rotated. |
a528ea8203ec
8145294: TestLogRotation.java triggers a race in the UL framework
mlarsson
parents:
35229
diff
changeset
|
577 |
for (size_t idx = 2; idx < _n_outputs; idx++) { |
a528ea8203ec
8145294: TestLogRotation.java triggers a race in the UL framework
mlarsson
parents:
35229
diff
changeset
|
578 |
_outputs[idx]->force_rotate(); |
34637
9b9298044d23
8140556: Add force rotation option to VM.log jcmd
ysuenaga
parents:
34316
diff
changeset
|
579 |
} |
9b9298044d23
8140556: Add force rotation option to VM.log jcmd
ysuenaga
parents:
34316
diff
changeset
|
580 |
} |
9b9298044d23
8140556: Add force rotation option to VM.log jcmd
ysuenaga
parents:
34316
diff
changeset
|
581 |
|
37108
fe800ec86077
8151264: Add a notification mechanism for UL configuration changes.
rehn
parents:
36174
diff
changeset
|
582 |
void LogConfiguration::register_update_listener(UpdateListenerFunction cb) { |
fe800ec86077
8151264: Add a notification mechanism for UL configuration changes.
rehn
parents:
36174
diff
changeset
|
583 |
assert(cb != NULL, "Should not register NULL as listener"); |
fe800ec86077
8151264: Add a notification mechanism for UL configuration changes.
rehn
parents:
36174
diff
changeset
|
584 |
ConfigurationLock cl; |
fe800ec86077
8151264: Add a notification mechanism for UL configuration changes.
rehn
parents:
36174
diff
changeset
|
585 |
size_t idx = _n_listener_callbacks++; |
fe800ec86077
8151264: Add a notification mechanism for UL configuration changes.
rehn
parents:
36174
diff
changeset
|
586 |
_listener_callbacks = REALLOC_C_HEAP_ARRAY(UpdateListenerFunction, |
fe800ec86077
8151264: Add a notification mechanism for UL configuration changes.
rehn
parents:
36174
diff
changeset
|
587 |
_listener_callbacks, |
fe800ec86077
8151264: Add a notification mechanism for UL configuration changes.
rehn
parents:
36174
diff
changeset
|
588 |
_n_listener_callbacks, |
fe800ec86077
8151264: Add a notification mechanism for UL configuration changes.
rehn
parents:
36174
diff
changeset
|
589 |
mtLogging); |
fe800ec86077
8151264: Add a notification mechanism for UL configuration changes.
rehn
parents:
36174
diff
changeset
|
590 |
_listener_callbacks[idx] = cb; |
fe800ec86077
8151264: Add a notification mechanism for UL configuration changes.
rehn
parents:
36174
diff
changeset
|
591 |
} |
fe800ec86077
8151264: Add a notification mechanism for UL configuration changes.
rehn
parents:
36174
diff
changeset
|
592 |
|
fe800ec86077
8151264: Add a notification mechanism for UL configuration changes.
rehn
parents:
36174
diff
changeset
|
593 |
void LogConfiguration::notify_update_listeners() { |
fe800ec86077
8151264: Add a notification mechanism for UL configuration changes.
rehn
parents:
36174
diff
changeset
|
594 |
assert(ConfigurationLock::current_thread_has_lock(), "notify_update_listeners must be called in ConfigurationLock scope (lock held)"); |
fe800ec86077
8151264: Add a notification mechanism for UL configuration changes.
rehn
parents:
36174
diff
changeset
|
595 |
for (size_t i = 0; i < _n_listener_callbacks; i++) { |
fe800ec86077
8151264: Add a notification mechanism for UL configuration changes.
rehn
parents:
36174
diff
changeset
|
596 |
_listener_callbacks[i](); |
fe800ec86077
8151264: Add a notification mechanism for UL configuration changes.
rehn
parents:
36174
diff
changeset
|
597 |
} |
fe800ec86077
8151264: Add a notification mechanism for UL configuration changes.
rehn
parents:
36174
diff
changeset
|
598 |
} |