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/chromedriver/logging.h" | 5 #include "chrome/test/chromedriver/logging.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
7 #include <stdio.h> | 9 #include <stdio.h> |
8 | 10 |
9 #include "base/basictypes.h" | |
10 #include "base/command_line.h" | 11 #include "base/command_line.h" |
11 #include "base/json/json_reader.h" | 12 #include "base/json/json_reader.h" |
12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/macros.h" |
13 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
14 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "build/build_config.h" |
15 #include "chrome/test/chromedriver/capabilities.h" | 18 #include "chrome/test/chromedriver/capabilities.h" |
16 #include "chrome/test/chromedriver/chrome/console_logger.h" | 19 #include "chrome/test/chromedriver/chrome/console_logger.h" |
17 #include "chrome/test/chromedriver/chrome/status.h" | 20 #include "chrome/test/chromedriver/chrome/status.h" |
18 #include "chrome/test/chromedriver/command_listener_proxy.h" | 21 #include "chrome/test/chromedriver/command_listener_proxy.h" |
19 #include "chrome/test/chromedriver/performance_logger.h" | 22 #include "chrome/test/chromedriver/performance_logger.h" |
20 #include "chrome/test/chromedriver/session.h" | 23 #include "chrome/test/chromedriver/session.h" |
21 | 24 |
22 #if defined(OS_POSIX) | 25 #if defined(OS_POSIX) |
23 #include <fcntl.h> | 26 #include <fcntl.h> |
24 #include <unistd.h> | 27 #include <unistd.h> |
25 #endif | 28 #endif |
26 | 29 |
27 | 30 |
28 namespace { | 31 namespace { |
29 | 32 |
30 Log::Level g_log_level = Log::kWarning; | 33 Log::Level g_log_level = Log::kWarning; |
31 | 34 |
32 int64 g_start_time = 0; | 35 int64_t g_start_time = 0; |
33 | 36 |
34 // Array indices are the Log::Level enum values. | 37 // Array indices are the Log::Level enum values. |
35 const char* const kLevelToName[] = { | 38 const char* const kLevelToName[] = { |
36 "ALL", // kAll | 39 "ALL", // kAll |
37 "DEBUG", // kDebug | 40 "DEBUG", // kDebug |
38 "INFO", // kInfo | 41 "INFO", // kInfo |
39 "WARNING", // kWarning | 42 "WARNING", // kWarning |
40 "SEVERE", // kError | 43 "SEVERE", // kError |
41 "OFF", // kOff | 44 "OFF", // kOff |
42 }; | 45 }; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 175 |
173 void WebDriverLog::AddEntryTimestamped(const base::Time& timestamp, | 176 void WebDriverLog::AddEntryTimestamped(const base::Time& timestamp, |
174 Log::Level level, | 177 Log::Level level, |
175 const std::string& source, | 178 const std::string& source, |
176 const std::string& message) { | 179 const std::string& message) { |
177 if (level < min_level_) | 180 if (level < min_level_) |
178 return; | 181 return; |
179 | 182 |
180 scoped_ptr<base::DictionaryValue> log_entry_dict(new base::DictionaryValue()); | 183 scoped_ptr<base::DictionaryValue> log_entry_dict(new base::DictionaryValue()); |
181 log_entry_dict->SetDouble("timestamp", | 184 log_entry_dict->SetDouble("timestamp", |
182 static_cast<int64>(timestamp.ToJsTime())); | 185 static_cast<int64_t>(timestamp.ToJsTime())); |
183 log_entry_dict->SetString("level", LevelToName(level)); | 186 log_entry_dict->SetString("level", LevelToName(level)); |
184 if (!source.empty()) | 187 if (!source.empty()) |
185 log_entry_dict->SetString("source", source); | 188 log_entry_dict->SetString("source", source); |
186 log_entry_dict->SetString("message", message); | 189 log_entry_dict->SetString("message", message); |
187 entries_->Append(log_entry_dict.release()); | 190 entries_->Append(log_entry_dict.release()); |
188 } | 191 } |
189 | 192 |
190 const std::string& WebDriverLog::type() const { | 193 const std::string& WebDriverLog::type() const { |
191 return type_; | 194 return type_; |
192 } | 195 } |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 logs.push_back(browser_log); | 288 logs.push_back(browser_log); |
286 // If the level is OFF, don't even bother listening for DevTools events. | 289 // If the level is OFF, don't even bother listening for DevTools events. |
287 if (browser_log_level != Log::kOff) | 290 if (browser_log_level != Log::kOff) |
288 devtools_listeners.push_back(new ConsoleLogger(browser_log)); | 291 devtools_listeners.push_back(new ConsoleLogger(browser_log)); |
289 | 292 |
290 out_logs->swap(logs); | 293 out_logs->swap(logs); |
291 out_devtools_listeners->swap(devtools_listeners); | 294 out_devtools_listeners->swap(devtools_listeners); |
292 out_command_listeners->swap(command_listeners); | 295 out_command_listeners->swap(command_listeners); |
293 return Status(kOk); | 296 return Status(kOk); |
294 } | 297 } |
OLD | NEW |