| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/trace_event.h" | 5 #include "base/trace_event.h" |
| 6 | 6 |
| 7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 126 |
| 127 #ifdef USE_UNRELIABLE_NOW | 127 #ifdef USE_UNRELIABLE_NOW |
| 128 TimeTicks tick = TimeTicks::HighResNow(); | 128 TimeTicks tick = TimeTicks::HighResNow(); |
| 129 #else | 129 #else |
| 130 TimeTicks tick = TimeTicks::Now(); | 130 TimeTicks tick = TimeTicks::Now(); |
| 131 #endif | 131 #endif |
| 132 TimeDelta delta = tick - trace_start_time_; | 132 TimeDelta delta = tick - trace_start_time_; |
| 133 int64 usec = delta.InMicroseconds(); | 133 int64 usec = delta.InMicroseconds(); |
| 134 std::string msg = | 134 std::string msg = |
| 135 StringPrintf("{'pid':'0x%lx', 'tid':'0x%lx', 'type':'%s', " | 135 StringPrintf("{'pid':'0x%lx', 'tid':'0x%lx', 'type':'%s', " |
| 136 "'name':'%s', 'id':'0x%lx', 'extra':'%s', 'file':'%s', " | 136 "'name':'%s', 'id':'%p', 'extra':'%s', 'file':'%s', " |
| 137 "'line_number':'%d', 'usec_begin': %" PRId64 "},\n", | 137 "'line_number':'%d', 'usec_begin': %" PRId64 "},\n", |
| 138 base::GetCurrentProcId(), | 138 static_cast<unsigned long>(base::GetCurrentProcId()), |
| 139 PlatformThread::CurrentId(), | 139 static_cast<unsigned long>(PlatformThread::CurrentId()), |
| 140 kEventTypeNames[type], | 140 kEventTypeNames[type], |
| 141 name.c_str(), | 141 name.c_str(), |
| 142 id, | 142 id, |
| 143 extra.c_str(), | 143 extra.c_str(), |
| 144 file, | 144 file, |
| 145 line, | 145 line, |
| 146 usec); | 146 usec); |
| 147 | 147 |
| 148 Log(msg); | 148 Log(msg); |
| 149 } | 149 } |
| 150 | 150 |
| 151 void TraceLog::Log(const std::string& msg) { | 151 void TraceLog::Log(const std::string& msg) { |
| 152 AutoLock lock(file_lock_); | 152 AutoLock lock(file_lock_); |
| 153 | 153 |
| 154 fprintf(log_file_, "%s", msg.c_str()); | 154 fprintf(log_file_, "%s", msg.c_str()); |
| 155 } | 155 } |
| 156 | 156 |
| 157 } // namespace base | 157 } // namespace base |
| OLD | NEW |