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

Side by Side Diff: chrome/test/webdriver/webdriver_logging.cc

Issue 9016024: Add option for not adding '.0' to the end of doubles that have no fractional (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 9 months 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 | Annotate | Revision Log
« no previous file with comments | « chrome/test/webdriver/commands/response.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/test/webdriver/webdriver_logging.h" 5 #include "chrome/test/webdriver/webdriver_logging.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 const FilePath& FileLog::path() const { 149 const FilePath& FileLog::path() const {
150 return path_; 150 return path_;
151 } 151 }
152 152
153 InMemoryLog::InMemoryLog() { } 153 InMemoryLog::InMemoryLog() { }
154 154
155 InMemoryLog::~InMemoryLog() { } 155 InMemoryLog::~InMemoryLog() { }
156 156
157 void InMemoryLog::Log(LogLevel level, const base::Time& time, 157 void InMemoryLog::Log(LogLevel level, const base::Time& time,
158 const std::string& message) { 158 const std::string& message) {
159 // base's JSONWriter doesn't obey the spec, and writes 159 base::TimeDelta delta = time - base::Time::UnixEpoch();
160 // doubles without a fraction with a '.0' postfix. base's Value class
161 // only includes doubles or int types. Instead of returning the timestamp
162 // in unix epoch time, we return it based on the start of chromedriver so
163 // a 32-bit int doesn't overflow.
164 // TODO(kkania): Add int64_t to base Values or fix the JSONWriter/Reader and
165 // use unix epoch time.
166 base::TimeDelta delta(time - base::Time::FromDoubleT(start_time));
167 DictionaryValue* entry = new DictionaryValue(); 160 DictionaryValue* entry = new DictionaryValue();
168 entry->SetInteger("level", level); 161 entry->SetInteger("level", level);
169 entry->SetInteger("timestamp", delta.InMilliseconds()); 162 entry->SetDouble("timestamp", std::floor(delta.InMillisecondsF()));
170 entry->SetString("message", message); 163 entry->SetString("message", message);
171 base::AutoLock auto_lock(entries_lock_); 164 base::AutoLock auto_lock(entries_lock_);
172 entries_list_.Append(entry); 165 entries_list_.Append(entry);
173 } 166 }
174 167
175 const ListValue* InMemoryLog::entries_list() const { 168 const ListValue* InMemoryLog::entries_list() const {
176 return &entries_list_; 169 return &entries_list_;
177 } 170 }
178 171
179 Logger::Logger() : min_log_level_(kAllLogLevel) { } 172 Logger::Logger() : min_log_level_(kAllLogLevel) { }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 log = FileLog::CreateFileLog(FILE_PATH_LITERAL("chromedriver.log"), 216 log = FileLog::CreateFileLog(FILE_PATH_LITERAL("chromedriver.log"),
224 min_log_level); 217 min_log_level);
225 } else { 218 } else {
226 log = new FileLog(log_path, min_log_level); 219 log = new FileLog(log_path, min_log_level);
227 } 220 }
228 FileLog::SetGlobalLog(log); 221 FileLog::SetGlobalLog(log);
229 return log->IsOpen(); 222 return log->IsOpen();
230 } 223 }
231 224
232 } // namespace webdriver 225 } // namespace webdriver
OLDNEW
« no previous file with comments | « chrome/test/webdriver/commands/response.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698