Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: base/trace_event.cc

Issue 339059: Add compiler-specific "examine printf format" attributes to printfs. (Closed)
Patch Set: cleanups Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698