@@ -110,9 +110,7 @@ void LogConfiguration::initialize(jlong vm_start_time) {
110
110
}
111
111
112
112
void LogConfiguration::finalize () {
113
- for (size_t i = _n_outputs; i > 0 ; i--) {
114
- disable_output (i - 1 );
115
- }
113
+ disable_outputs ();
116
114
FREE_C_HEAP_ARRAY (LogOutput*, _outputs);
117
115
}
118
116
@@ -272,28 +270,31 @@ void LogConfiguration::configure_output(size_t idx, const LogSelectionList& sele
272
270
assert (strlen (output->config_string ()) > 0 , " should always have a config description" );
273
271
}
274
272
275
- void LogConfiguration::disable_output (size_t idx) {
276
- assert (idx < _n_outputs, " invalid index: " SIZE_FORMAT " (_n_outputs: " SIZE_FORMAT " )" , idx, _n_outputs);
277
- LogOutput* out = _outputs[idx];
273
+ void LogConfiguration::disable_outputs () {
274
+ size_t idx = _n_outputs;
278
275
279
- // Remove the output from all tagsets.
276
+ // Remove all outputs from all tagsets.
280
277
for (LogTagSet* ts = LogTagSet::first (); ts != NULL ; ts = ts->next ()) {
281
- ts->set_output_level (out, LogLevel::Off);
282
- ts->update_decorators ();
278
+ ts->disable_outputs ();
283
279
}
284
280
285
- // Delete the output unless stdout or stderr (idx 0 or 1)
286
- if (idx > 1 ) {
287
- delete_output (idx);
288
- } else {
289
- out->set_config_string (" all=off" );
281
+ while (idx > 0 ) {
282
+ LogOutput* out = _outputs[--idx];
283
+ // Delete the output unless stdout or stderr (idx 0 or 1)
284
+ if (idx > 1 ) {
285
+ delete_output (idx);
286
+ } else {
287
+ out->set_config_string (" all=off" );
288
+ }
290
289
}
291
290
}
292
291
293
292
void LogConfiguration::disable_logging () {
294
293
ConfigurationLock cl;
295
- for (size_t i = _n_outputs; i > 0 ; i--) {
296
- disable_output (i - 1 );
294
+ disable_outputs ();
295
+ // Update the decorators on all tagsets to get rid of unused decorators
296
+ for (LogTagSet* ts = LogTagSet::first (); ts != NULL ; ts = ts->next ()) {
297
+ ts->update_decorators ();
297
298
}
298
299
notify_update_listeners ();
299
300
}
0 commit comments