diff --git a/lib/logging.js b/lib/logging.js index f95f6d6..2535273 100644 --- a/lib/logging.js +++ b/lib/logging.js @@ -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);