blob: 7eadc04cbdab27066c7e21bfe0b1161b46aaa5f3 [file] [log] [blame]
zhenwc5db2a02015-12-11 23:31:431// Copyright (c) 2015 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "components/tracing/trace_to_console.h"
6
7#include <string>
8
9#include "base/command_line.h"
10#include "components/tracing/tracing_switches.h"
11
12namespace tracing {
13
14namespace {
15// These categories will cause deadlock when ECHO_TO_CONSOLE. crbug.com/325575.
wangxianzhuf4fb38042015-12-21 16:08:1216const char kEchoToConsoleCategoryFilter[] = "-ipc,-toplevel";
zhenwc5db2a02015-12-11 23:31:4317} // namespace
18
19base::trace_event::TraceConfig GetConfigForTraceToConsole() {
20 const base::CommandLine& command_line =
21 *base::CommandLine::ForCurrentProcess();
22 DCHECK(command_line.HasSwitch(switches::kTraceToConsole));
23 std::string filter = command_line.GetSwitchValueASCII(
24 switches::kTraceToConsole);
25 if (filter.empty()) {
26 filter = kEchoToConsoleCategoryFilter;
27 } else {
28 filter.append(",");
29 filter.append(kEchoToConsoleCategoryFilter);
30 }
31 return base::trace_event::TraceConfig(
32 filter, base::trace_event::ECHO_TO_CONSOLE);
33}
34
35} // namespace tracing