Chromium Code Reviews| 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 <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 VLOG(1) << "Log type '" << type_ << "' lost " | 143 VLOG(1) << "Log type '" << type_ << "' lost " |
| 144 << entries_->GetSize() << " entries on destruction"; | 144 << entries_->GetSize() << " entries on destruction"; |
| 145 } | 145 } |
| 146 | 146 |
| 147 scoped_ptr<base::ListValue> WebDriverLog::GetAndClearEntries() { | 147 scoped_ptr<base::ListValue> WebDriverLog::GetAndClearEntries() { |
| 148 scoped_ptr<base::ListValue> ret(entries_.release()); | 148 scoped_ptr<base::ListValue> ret(entries_.release()); |
| 149 entries_.reset(new base::ListValue()); | 149 entries_.reset(new base::ListValue()); |
| 150 return ret.Pass(); | 150 return ret.Pass(); |
| 151 } | 151 } |
| 152 | 152 |
| 153 std::string WebDriverLog::GetFirstErrorMessage() const { | |
|
chrisgao (Use stgao instead)
2014/01/09 22:11:55
How do you handle error messages resulted from the
samuong
2014/01/16 00:29:28
In this case the error from navigation1 will get a
| |
| 154 for (base::ListValue::iterator it = entries_->begin(); | |
| 155 it != entries_->end(); | |
| 156 ++it) { | |
| 157 base::DictionaryValue* log_entry = NULL; | |
| 158 (*it)->GetAsDictionary(&log_entry); | |
| 159 if (log_entry != NULL) { | |
| 160 std::string level; | |
| 161 if (log_entry->GetString("level", &level)) { | |
| 162 if (level.compare(kLevelToName[Log::kError]) == 0) { | |
|
chrisgao (Use stgao instead)
2014/01/09 22:11:55
level == kLevelToName[Log::kError] ?
samuong
2014/01/16 00:29:28
Done. Obviously I'm still working on kicking the J
| |
| 163 std::string message; | |
| 164 if (log_entry->GetString("message", &message)) | |
| 165 return message; | |
|
chrisgao (Use stgao instead)
2014/01/09 22:11:55
If we do not clear the error message from the list
samuong
2014/01/16 00:29:28
When an error is auto-reported, I think most clien
| |
| 166 } | |
| 167 } | |
| 168 } | |
| 169 } | |
| 170 return ""; | |
|
chrisgao (Use stgao instead)
2014/01/09 22:11:55
"" -> std::string()
samuong
2014/01/16 00:29:28
Done.
| |
| 171 } | |
| 172 | |
| 153 void WebDriverLog::AddEntryTimestamped(const base::Time& timestamp, | 173 void WebDriverLog::AddEntryTimestamped(const base::Time& timestamp, |
| 154 Log::Level level, | 174 Log::Level level, |
| 155 const std::string& source, | 175 const std::string& source, |
| 156 const std::string& message) { | 176 const std::string& message) { |
| 157 if (level < min_level_) | 177 if (level < min_level_) |
| 158 return; | 178 return; |
| 159 | 179 |
| 160 scoped_ptr<base::DictionaryValue> log_entry_dict(new base::DictionaryValue()); | 180 scoped_ptr<base::DictionaryValue> log_entry_dict(new base::DictionaryValue()); |
| 161 log_entry_dict->SetDouble("timestamp", | 181 log_entry_dict->SetDouble("timestamp", |
| 162 static_cast<int64>(timestamp.ToJsTime())); | 182 static_cast<int64>(timestamp.ToJsTime())); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 new WebDriverLog(WebDriverLog::kBrowserType, browser_log_level); | 271 new WebDriverLog(WebDriverLog::kBrowserType, browser_log_level); |
| 252 logs.push_back(browser_log); | 272 logs.push_back(browser_log); |
| 253 // If the level is OFF, don't even bother listening for DevTools events. | 273 // If the level is OFF, don't even bother listening for DevTools events. |
| 254 if (browser_log_level != Log::kOff) | 274 if (browser_log_level != Log::kOff) |
| 255 listeners.push_back(new ConsoleLogger(browser_log)); | 275 listeners.push_back(new ConsoleLogger(browser_log)); |
| 256 | 276 |
| 257 out_logs->swap(logs); | 277 out_logs->swap(logs); |
| 258 out_listeners->swap(listeners); | 278 out_listeners->swap(listeners); |
| 259 return Status(kOk); | 279 return Status(kOk); |
| 260 } | 280 } |
| OLD | NEW |