| Index: base/debug/trace_event_impl.cc
|
| diff --git a/base/debug/trace_event_impl.cc b/base/debug/trace_event_impl.cc
|
| index d97c4618e904e0fdbecfe4bab73a3eee25f3b98b..0a89b9ddcfd38b4ffbd4e1def92972a2aaa2bce0 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)) {
|
| + std::string category_string =
|
| + CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
|
| + switches::kTraceToConsole);
|
| +
|
| + if (category_string.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();
|
|
|