Commit ecdff43b authored by lpy's avatar lpy Committed by Commit bot

[Tracing] Support multi-categories group list.

jasongin@ created this patch.
https://github.com/jasongin/nodejs/commit/dcc50445a364664586164f42f9250732bd372982
This patch adds the support to emit a trace event by using a comma-separated
list of categories, so that the trace event will be emitted if there is at least
one category is enabled in the categories list.

TBR=jochen@chromium.org

Review-Url: https://codereview.chromium.org/2558193002
Cr-Commit-Position: refs/heads/master@{#41567}
parent c7c19c86
......@@ -21,8 +21,13 @@ TraceConfig* TraceConfig::CreateDefaultTraceConfig() {
}
bool TraceConfig::IsCategoryGroupEnabled(const char* category_group) const {
for (auto included_category : included_categories_) {
if (strcmp(included_category.data(), category_group) == 0) return true;
std::stringstream category_stream(category_group);
while (category_stream.good()) {
std::string category;
getline(category_stream, category, ',');
for (auto included_category : included_categories_) {
if (category == included_category) return true;
}
}
return false;
}
......
......@@ -25,6 +25,14 @@ TEST(TestTraceConfig) {
CHECK_EQ(trace_config->IsCategoryGroupEnabled(
TRACE_DISABLED_BY_DEFAULT("v8.runtime")),
true);
CHECK_EQ(trace_config->IsCategoryGroupEnabled("v8,v8.cpu_profile"), true);
CHECK_EQ(
trace_config->IsCategoryGroupEnabled("v8,disabled-by-default-v8.runtime"),
true);
CHECK_EQ(trace_config->IsCategoryGroupEnabled(
"v8_cpu_profile,v8.cpu_profile.hires"),
false);
delete trace_config;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment