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

Side by Side Diff: chrome/test/chromedriver/logging.cc

Issue 101203012: [chromedriver] Add an error autoreporting feature that automatically raises errors from browser logs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from review Created 6 years, 11 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
« no previous file with comments | « chrome/test/chromedriver/logging.h ('k') | chrome/test/chromedriver/logging_unittest.cc » ('j') | 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/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
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 {
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 == kLevelToName[Log::kError]) {
163 std::string message;
164 if (log_entry->GetString("message", &message))
165 return message;
166 }
167 }
168 }
169 }
170 return std::string();
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
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 }
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/logging.h ('k') | chrome/test/chromedriver/logging_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698