-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconsolewrapper.js
99 lines (99 loc) · 3.08 KB
/
consolewrapper.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
var newConsole = (function(oldConsole)
{
return {
log : function()
{
var data = [];
for (var _i = 0; _i < arguments.length; _i++) {
data[_i] = arguments[_i];
}
if(data.length == 1) //Start looking for api's (And dont show anything)
{
if(typeof(data[0]) == "string" && data[0].indexOf("callJavascriptFunction") != -1) //Contains function
{
// oldConsole.log(data[0]);
try
{
return eval(data[0].split("callJavascriptFunction ")[1]);
}
catch(e)
{
oldConsole.error("Something went wrong with your callJS: \nCode: " + data[0].split("callJavascriptFunction ")[1] + "\nError: '" + e.message + "'");
return null;
}
}
else
{
oldConsole.log(data[0]);
return null;
}
}
else
oldConsole.log(data[0], data.splice(1));
return null;
},
info : function()
{
var data = [];
for (var _i = 0; _i < arguments.length; _i++) {
data[_i] = arguments[_i];
}
if(data.length == 1)
oldConsole.info(data[0]);
else
oldConsole.info(data[0], data.splice(1));
},
warn : function()
{
var data = [];
for (var _i = 0; _i < arguments.length; _i++) {
data[_i] = arguments[_i];
}
if(data.length == 1)
oldConsole.warn(data[0]);
else
oldConsole.warn(data[0], data.splice(1));
},
error : function()
{
var data = [];
for (var _i = 0; _i < arguments.length; _i++) {
data[_i] = arguments[_i];
}
if(data.length == 1)
oldConsole.error(data[0]);
else
oldConsole.error(data[0], data.splice(1));
},
clear : function()
{
oldConsole.clear()
},
assert : function()
{
for (var _i = 0; _i < arguments.length; _i++) {
data[_i] = arguments[_i];
}
oldConsole.assert(data[0], data[1], data.splice(2));
},
group : function()
{
for (var _i = 0; _i < arguments.length; _i++) {
data[_i] = arguments[_i];
}
oldConsole.group(data[0], data.splice(1));
},
groupCollapsed : function()
{
for (var _i = 0; _i < arguments.length; _i++) {
data[_i] = arguments[_i];
}
oldConsole.groupCollapsed(data[0], data.splice(1));
},
groupEnd : function()
{
oldConsole.groupEnd()
}
}
}(window.console));
window.console = newConsole;