UNPKG

n-console

Version:

js console style

45 lines (38 loc) 1.08 kB
var stylePre = '%c'; var defaultStyle = "line-height:16px;font-size:14px;padding:4px;background:#fff;color:#12c256;"; function startStyle(defaultStyle) { return defaultStyle + "font-size:12px;background:#12c256;color:#fff;border-radius:12px;"; } function endStyle(defaultStyle) { return defaultStyle + "font-size:12px;background:orange;color:#fff;border-radius:12px;"; } function normal(name) { console.log(`${stylePre}[ ${name} ]`, defaultStyle); } function start(name) { console.log(`${stylePre}[ ${name} ] ${stylePre} - start - `, defaultStyle, startStyle(defaultStyle)); } function end(name) { console.log(`${stylePre}[ ${name} ] ${stylePre} - end - `, defaultStyle, endStyle(defaultStyle)); } if(console) { // Object.assign(console, { // normal: normal, // start: start, // end: end // }) console.normal = normal; console.start = start; console.end = end; } else { window.console = { normal: normal, start: start, end: end } } module.exports = { normal: normal, start: start, end: end };