1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_TEST_CHROMEDRIVER_CHROME_CONSOLE_LOGGER_H_
6 #define CHROME_TEST_CHROMEDRIVER_CHROME_CONSOLE_LOGGER_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "chrome/test/chromedriver/chrome/devtools_event_listener.h"
14 // Translates DevTools Console.messageAdded events into Log messages.
16 // The message format, in terms of Console.ConsoleMessage fields, is:
17 // "<url or source> [<line>[:<column>]] text"
19 // Translates the level into Log::Level, drops all other fields.
20 class ConsoleLogger : public DevToolsEventListener {
22 // Creates a ConsoleLogger that creates entries in the given Log object.
23 // The log is owned elsewhere and must not be null.
24 explicit ConsoleLogger(Log* log);
26 // Enables Console events for the client, which must not be null.
27 Status OnConnected(DevToolsClient* client) override;
28 // Translates an event into a log entry.
29 Status OnEvent(DevToolsClient* client,
30 const std::string& method,
31 const base::DictionaryValue& params) override;
34 Log* log_; // The log where to create entries.
36 DISALLOW_COPY_AND_ASSIGN(ConsoleLogger);
39 #endif // CHROME_TEST_CHROMEDRIVER_CHROME_CONSOLE_LOGGER_H_