< prev index next >

src/share/vm/logging/logTagSet.cpp

Print this page
rev 11119 : [mq]: 8146948

*** 25,35 **** --- 25,37 ---- #include "logging/logDecorations.hpp" #include "logging/logLevel.hpp" #include "logging/logOutput.hpp" #include "logging/logTag.hpp" #include "logging/logTagSet.hpp" + #include "logging/logTagSetDescriptions.inline.hpp" #include "memory/allocation.inline.hpp" + #include "utilities/ostream.hpp" LogTagSet* LogTagSet::_list = NULL; size_t LogTagSet::_ntagsets = 0; // This constructor is called only during static initialization.
*** 117,121 **** --- 119,164 ---- } else { log(level, buf); } va_end(saved_args); } + + static const size_t TagSetBufferSize = 128; + + void LogTagSet::describe_tagsets(outputStream* out) { + out->print_cr("Described tag combinations:"); + for (const LogTagSetDescription* d = tagset_descriptions; d->tagset != NULL; d++) { + char buf[TagSetBufferSize]; + d->tagset->label(buf, sizeof(buf), "+"); + out->print_cr(" %s: %s", buf, d->descr); + } + } + + static int qsort_strcmp(const void* a, const void* b) { + return strcmp((*(const char**)a), (*(const char**)b)); + } + + void LogTagSet::list_all_tagsets(outputStream* out) { + char** tagset_labels = NEW_C_HEAP_ARRAY(char*, _ntagsets, mtLogging); + + // Generate the list of tagset labels + size_t idx = 0; + for (LogTagSet* ts = first(); ts != NULL; ts = ts->next()) { + char buf[TagSetBufferSize]; + ts->label(buf, sizeof(buf), "+"); + tagset_labels[idx++] = os::strdup_check_oom(buf, mtLogging); + } + assert(idx == _ntagsets, "_ntagsets and list of tagsets not in sync"); + + // Sort them lexicographically + qsort(tagset_labels, _ntagsets, sizeof(*tagset_labels), qsort_strcmp); + + // Print and then free the labels + out->print("All available tag sets: "); + for (idx = 0; idx < _ntagsets; idx++) { + out->print("%s%s", (idx == 0 ? "" : ", "), tagset_labels[idx]); + os::free(tagset_labels[idx]); + } + out->cr(); + FREE_C_HEAP_ARRAY(char*, tagset_labels); + } +
< prev index next >