Chromium Code Reviews| Index: base/debug/trace_event_impl.cc |
| diff --git a/base/debug/trace_event_impl.cc b/base/debug/trace_event_impl.cc |
| index 0885cab65c7a62943e6ef00795334415e659db39..de74d3d215589ca2d6c3cc00e7bfb2c7492b6f55 100644 |
| --- a/base/debug/trace_event_impl.cc |
| +++ b/base/debug/trace_event_impl.cc |
| @@ -6,7 +6,9 @@ |
| #include <algorithm> |
| +#include "base/base_switches.h" |
| #include "base/bind.h" |
| +#include "base/command_line.h" |
| #include "base/debug/leak_annotations.h" |
| #include "base/debug/trace_event.h" |
| #include "base/format_macros.h" |
| @@ -801,6 +803,17 @@ TraceLog::TraceLog() |
| #endif |
| logged_events_.reset(GetTraceBuffer()); |
| + |
| + if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTraceToConsole)) { |
|
willchan no longer on Chromium
2013/07/03 17:55:19
Not super fond of this, but since nduca is fine wi
|
| + std::string category_string = |
| + CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| + switches::kTraceToConsole); |
| + |
| + if (!category_string.size()) |
|
willchan no longer on Chromium
2013/07/03 17:55:19
STL doesn't specify the algorithmic complexity of
Ian Vollick
2013/07/03 18:48:03
Switched to empty().
|
| + category_string = "*"; |
| + |
| + SetEnabled(CategoryFilter(category_string), ECHO_TO_CONSOLE); |
| + } |
| } |
| TraceLog::~TraceLog() { |
| @@ -1064,7 +1077,7 @@ void TraceLog::SetNotificationCallback( |
| TraceBuffer* TraceLog::GetTraceBuffer() { |
| if (trace_options_ & RECORD_CONTINUOUSLY) |
| return new TraceBufferRingBuffer(); |
| - else if (trace_options_ & ECHO_TO_VLOG) |
| + else if (trace_options_ & ECHO_TO_CONSOLE) |
| return new TraceBufferDiscardsEvents(); |
| return new TraceBufferVector(); |
| } |
| @@ -1136,7 +1149,7 @@ void TraceLog::AddTraceEventWithThreadIdAndTimestamp( |
| DCHECK(name); |
| TimeDelta duration; |
| - if (phase == TRACE_EVENT_PHASE_END && trace_options_ & ECHO_TO_VLOG) { |
| + if (phase == TRACE_EVENT_PHASE_END && trace_options_ & ECHO_TO_CONSOLE) { |
| duration = timestamp - thread_event_start_times_[thread_id].top(); |
| thread_event_start_times_[thread_id].pop(); |
| } |
| @@ -1194,7 +1207,7 @@ void TraceLog::AddTraceEventWithThreadIdAndTimestamp( |
| } |
| } |
| - if (trace_options_ & ECHO_TO_VLOG) { |
| + if (trace_options_ & ECHO_TO_CONSOLE) { |
| std::string thread_name = thread_names_[thread_id]; |
| if (thread_colors_.find(thread_name) == thread_colors_.end()) |
| thread_colors_[thread_name] = (thread_colors_.size() % 6) + 1; |
| @@ -1217,7 +1230,7 @@ void TraceLog::AddTraceEventWithThreadIdAndTimestamp( |
| if (phase == TRACE_EVENT_PHASE_END) |
| log << base::StringPrintf(" (%.3f ms)", duration.InMillisecondsF()); |
| - VLOG(0) << log.str() << "\x1b[0;m"; |
| + LOG(ERROR) << log.str() << "\x1b[0;m"; |
| } |
| logged_events_->AddEvent(TraceEvent(thread_id, |
| @@ -1232,7 +1245,7 @@ void TraceLog::AddTraceEventWithThreadIdAndTimestamp( |
| notifier.AddNotificationWhileLocked(EVENT_WATCH_NOTIFICATION); |
| } while (0); // release lock |
| - if (phase == TRACE_EVENT_PHASE_BEGIN && trace_options_ & ECHO_TO_VLOG) |
| + if (phase == TRACE_EVENT_PHASE_BEGIN && trace_options_ & ECHO_TO_CONSOLE) |
| thread_event_start_times_[thread_id].push(timestamp); |
| notifier.SendNotificationIfAny(); |