| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |