-
Notifications
You must be signed in to change notification settings - Fork 0
/
KCConsole.js
37 lines (32 loc) · 1.09 KB
/
KCConsole.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// This file consist of an excerpt copied from the Chromium project sample
// with several modifications
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
function Console() {
}
Console.Type = {
LOG: "log",
DEBUG: "debug",
INFO: "info",
WARN: "warn",
ERROR: "error",
GROUP: "group",
GROUP_COLLAPSED: "groupCollapsed",
GROUP_END: "groupEnd"
};
Console.addMessage = function (type, format, args) {
chrome.runtime.sendMessage({
command: "sendToConsole",
tabId: chrome.devtools.tabId,
args: escape(JSON.stringify(Array.prototype.slice.call(arguments, 0)))
});
};
// Generate Console output methods, i.e. Console.log(), Console.debug() etc.
(function () {
var console_types = Object.getOwnPropertyNames(Console.Type);
for (var type = 0; type < console_types.length; ++type) {
var method_name = Console.Type[console_types[type]];
Console[method_name] = Console.addMessage.bind(Console, method_name);
}
})();