mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-01-03 10:31:54 +01:00
Added colors to the logging
This commit is contained in:
parent
96b5291459
commit
3d05b48089
@ -25,6 +25,15 @@
|
||||
return char.repeat(pad - str.length) + str;
|
||||
}
|
||||
|
||||
var colors = {
|
||||
1: "color: red",
|
||||
25: "color: orange",
|
||||
50: "",
|
||||
75: "color: darkgreen",
|
||||
100: "color: blue",
|
||||
999: "background-color: lightgray"
|
||||
};
|
||||
|
||||
var queue = [];
|
||||
function performLog(level, args, date){
|
||||
if (!date){
|
||||
@ -35,9 +44,9 @@
|
||||
}
|
||||
else {
|
||||
if (settings.logLevel >= level){
|
||||
var pre = "";
|
||||
var pre = "%c";
|
||||
if (prefix){
|
||||
pre = prefix + ": ";
|
||||
pre += prefix + ": ";
|
||||
}
|
||||
pre += "[" +
|
||||
date.getFullYear() + "-" +
|
||||
@ -50,8 +59,10 @@
|
||||
"]";
|
||||
if (typeof args[0] === "string"){
|
||||
args[0] = pre + " " + args[0];
|
||||
args.splice(1, 0, colors[level]);
|
||||
}
|
||||
else {
|
||||
args.unshift(colors[level]);
|
||||
args.unshift(pre);
|
||||
}
|
||||
console.log.apply(console, args);
|
||||
|
Loading…
x
Reference in New Issue
Block a user