mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-01-20 18:38:32 +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;
|
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 = [];
|
var queue = [];
|
||||||
function performLog(level, args, date){
|
function performLog(level, args, date){
|
||||||
if (!date){
|
if (!date){
|
||||||
@ -35,9 +44,9 @@
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (settings.logLevel >= level){
|
if (settings.logLevel >= level){
|
||||||
var pre = "";
|
var pre = "%c";
|
||||||
if (prefix){
|
if (prefix){
|
||||||
pre = prefix + ": ";
|
pre += prefix + ": ";
|
||||||
}
|
}
|
||||||
pre += "[" +
|
pre += "[" +
|
||||||
date.getFullYear() + "-" +
|
date.getFullYear() + "-" +
|
||||||
@ -50,8 +59,10 @@
|
|||||||
"]";
|
"]";
|
||||||
if (typeof args[0] === "string"){
|
if (typeof args[0] === "string"){
|
||||||
args[0] = pre + " " + args[0];
|
args[0] = pre + " " + args[0];
|
||||||
|
args.splice(1, 0, colors[level]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
args.unshift(colors[level]);
|
||||||
args.unshift(pre);
|
args.unshift(pre);
|
||||||
}
|
}
|
||||||
console.log.apply(console, args);
|
console.log.apply(console, args);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user