blob: b62bc1dd5f228b0d926fcfe1867109886473bf74 [file] [log] [blame]
[email protected]f55c90ee62014-04-12 00:50:031// Copyright 2014 The Chromium Authors. All rights reserved.
[email protected]d2663612013-03-17 09:25:562// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]f55c90ee62014-04-12 00:50:035#ifndef EXTENSIONS_RENDERER_CONSOLE_H_
6#define EXTENSIONS_RENDERER_CONSOLE_H_
[email protected]d2663612013-03-17 09:25:567
8#include <string>
9
Abhijeet Kandalkara5928a0a2019-03-13 05:04:4210#include "third_party/blink/public/mojom/devtools/console_message.mojom.h"
[email protected]d2663612013-03-17 09:25:5611#include "v8/include/v8.h"
12
[email protected]d2663612013-03-17 09:25:5613namespace extensions {
rdevlin.croninbaa379d2017-04-19 20:49:3114class ScriptContext;
[email protected]d2663612013-03-17 09:25:5615
rdevlin.croninbaa379d2017-04-19 20:49:3116// Utility for logging console messages.
[email protected]d2663612013-03-17 09:25:5617namespace console {
18
rdevlin.croninbaa379d2017-04-19 20:49:3119// Adds |message| to the console of of the |script_context|. If |script_context|
20// is null, LOG()s the message instead.
21void AddMessage(ScriptContext* script_context,
Abhijeet Kandalkara5928a0a2019-03-13 05:04:4222 blink::mojom::ConsoleMessageLevel level,
[email protected]d2663612013-03-17 09:25:5623 const std::string& message);
24
jbromanb1ad11a2017-02-27 23:59:2425// Logs an Error then crashes the current process.
rdevlin.croninbaa379d2017-04-19 20:49:3126void Fatal(ScriptContext* context, const std::string& message);
jbromanb1ad11a2017-02-27 23:59:2427
[email protected]7205a9c2013-08-03 03:15:0028// Returns a new v8::Object with each standard log method (Debug/Log/Warn/Error)
29// bound to respective debug/log/warn/error methods. This is a direct drop-in
30// replacement for the standard devtools console.* methods usually accessible
31// from JS.
kalmanfb6f10ac2014-11-06 23:55:3532v8::Local<v8::Object> AsV8Object(v8::Isolate* isolate);
[email protected]7205a9c2013-08-03 03:15:0033
[email protected]d2663612013-03-17 09:25:5634} // namespace console
35
36} // namespace extensions
37
[email protected]f55c90ee62014-04-12 00:50:0338#endif // EXTENSIONS_RENDERER_CONSOLE_H_