| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 void FileLog::set_min_log_level(LogLevel level) { | 134 void FileLog::set_min_log_level(LogLevel level) { |
| 135 min_log_level_ = level; | 135 min_log_level_ = level; |
| 136 } | 136 } |
| 137 | 137 |
| 138 InMemoryLog::InMemoryLog() { } | 138 InMemoryLog::InMemoryLog() { } |
| 139 | 139 |
| 140 InMemoryLog::~InMemoryLog() { } | 140 InMemoryLog::~InMemoryLog() { } |
| 141 | 141 |
| 142 void InMemoryLog::Log(LogLevel level, const base::Time& time, | 142 void InMemoryLog::Log(LogLevel level, const base::Time& time, |
| 143 const std::string& message) { | 143 const std::string& message) { |
| 144 // base's JSONWriter doesn't obey the spec, and writes | 144 base::TimeDelta delta = time - base::Time::UnixEpoch(); |
| 145 // doubles without a fraction with a '.0' postfix. base's Value class | |
| 146 // only includes doubles or int types. Instead of returning the timestamp | |
| 147 // in unix epoch time, we return it based on the start of chromedriver so | |
| 148 // a 32-bit int doesn't overflow. | |
| 149 // TODO(kkania): Add int64_t to base Values or fix the JSONWriter/Reader and | |
| 150 // use unix epoch time. | |
| 151 base::TimeDelta delta(time - base::Time::FromDoubleT(start_time)); | |
| 152 DictionaryValue* entry = new DictionaryValue(); | 145 DictionaryValue* entry = new DictionaryValue(); |
| 153 entry->SetInteger("level", level); | 146 entry->SetInteger("level", level); |
| 154 entry->SetInteger("timestamp", delta.InMilliseconds()); | 147 entry->SetDouble("timestamp", std::floor(delta.InMilliseconds())); |
| 155 entry->SetString("message", message); | 148 entry->SetString("message", message); |
| 156 base::AutoLock auto_lock(entries_lock_); | 149 base::AutoLock auto_lock(entries_lock_); |
| 157 entries_list_.Append(entry); | 150 entries_list_.Append(entry); |
| 158 } | 151 } |
| 159 | 152 |
| 160 const ListValue* InMemoryLog::entries_list() const { | 153 const ListValue* InMemoryLog::entries_list() const { |
| 161 return &entries_list_; | 154 return &entries_list_; |
| 162 } | 155 } |
| 163 | 156 |
| 164 Logger::Logger() : min_log_level_(kAllLogLevel) { } | 157 Logger::Logger() : min_log_level_(kAllLogLevel) { } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 logging::SetLogItems(false, // enable_process_id | 193 logging::SetLogItems(false, // enable_process_id |
| 201 false, // enable_thread_id | 194 false, // enable_thread_id |
| 202 true, // enable_timestamp | 195 true, // enable_timestamp |
| 203 false); // enable_tickcount | 196 false); // enable_tickcount |
| 204 | 197 |
| 205 // Init global file log. | 198 // Init global file log. |
| 206 FileLog::InitGlobalLog(min_log_level); | 199 FileLog::InitGlobalLog(min_log_level); |
| 207 } | 200 } |
| 208 | 201 |
| 209 } // namespace webdriver | 202 } // namespace webdriver |
| OLD | NEW |