UNPKG

logt

Version:

🖥️ A colourful logger for the browser

2 lines 3.74 kB
/*! For license information please see logt.min.js.LICENSE.txt */ (()=>{"use strict";var e={465:function(e,o){var r=this&&this.__spreadArray||function(e,o,r){if(r||2===arguments.length)for(var n,t=0,l=o.length;t<l;t++)!n&&t in o||(n||(n=Array.prototype.slice.call(o,0,t)),n[t]=o[t]);return e.concat(n||Array.prototype.slice.call(o))};Object.defineProperty(o,"__esModule",{value:!0});var n={none:-1,error:0,warn:1,info:2,verbose:3,debug:4,silly:5},t={error:"color: white; background: #db2828; border-radius: 8px",warn:"color: white; background: #fbbd08; border-radius: 8px",info:"color: white; background: #c4c64f; border-radius: 8px",verbose:"color: white; background: #6435c9; border-radius: 8px",debug:"color: white; background: #2185d0; border-radius: 8px",silly:"color: white; background: #21ba45; border-radius: 8px",tag:"color: black; background: #5bfff4; border-radius: 8px"};o.default=function(e){var o=this;this.logLevel=n.none,this.hidden=[],this.loggerMap={0:{text:"error",logger:console.error},1:{text:"warn",logger:console.warn},2:{text:"info",logger:console.info},3:{text:"verbose",logger:console.log},4:{text:"debug",logger:console.debug},5:{text:"silly",logger:console.log}},this.log=function(e,n,l){for(var i=[],a=3;a<arguments.length;a++)i[a-3]=arguments[a];e<=o.logLevel?o.loggerMap[e]&&o.loggerMap[e].logger.apply(void 0,r(["%c ".concat(o.loggerMap[e].text," %c %c ").concat(n," "),t[o.loggerMap[e].text],"",t.tag,l],i,!1)):o.hidden.push({level:e,tag:n,message:l,parts:i})},this.getLogLevel=function(){return o.logLevel},this.getFinalLevel=function(e){if(null!=e){if("string"==typeof e&&null!=n[e])return n[e];if("number"==typeof e&&e>=n.none&&e<=n.silly)return e}return n.none},this.setLogLevel=function(e){o.logLevel=o.getFinalLevel(e)},this.error=function(e,t){for(var l=[],i=2;i<arguments.length;i++)l[i-2]=arguments[i];o.log.apply(o,r([n.error,e,t],l,!1))},this.warn=function(e,t){for(var l=[],i=2;i<arguments.length;i++)l[i-2]=arguments[i];o.log.apply(o,r([n.warn,e,t],l,!1))},this.info=function(e,t){for(var l=[],i=2;i<arguments.length;i++)l[i-2]=arguments[i];o.log.apply(o,r([n.info,e,t],l,!1))},this.verbose=function(e,t){for(var l=[],i=2;i<arguments.length;i++)l[i-2]=arguments[i];o.log.apply(o,r([n.verbose,e,t],l,!1))},this.debug=function(e,t){for(var l=[],i=2;i<arguments.length;i++)l[i-2]=arguments[i];o.log.apply(o,r([n.debug,e,t],l,!1))},this.silly=function(e,t){for(var l=[],i=2;i<arguments.length;i++)l[i-2]=arguments[i];o.log.apply(o,r([n.silly,e,t],l,!1))},this.showHidden=function(e){var n=o.logLevel;o.setLogLevel(e);var t=o.hidden;o.hidden=[],t.forEach((function(e){o.log.apply(o,r([e.level,e.tag,e.message],e.parts,!1))})),o.setLogLevel(n)},this.readConsole=function(){var e="console";console.error=function(n){for(var t=[],l=1;l<arguments.length;l++)t[l-1]=arguments[l];o.error.apply(o,r([e,n],t,!1))},console.warn=function(n){for(var t=[],l=1;l<arguments.length;l++)t[l-1]=arguments[l];o.warn.apply(o,r([e,n],t,!1))},console.info=function(n){for(var t=[],l=1;l<arguments.length;l++)t[l-1]=arguments[l];o.info.apply(o,r([e,n],t,!1))},console.log=function(n){for(var t=[],l=1;l<arguments.length;l++)t[l-1]=arguments[l];o.debug.apply(o,r([e,n],t,!1))}},this.image=function(e,r,n){o.warn("logImage","This method is deprecated. Newwer versions of Chrome no longer support logging images.")},this.setLogLevel(e)}},390:function(e,o,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0});var t=n(r(465));window&&(window.createLogger=function(e){return new t.default(e)})}},o={};!function r(n){var t=o[n];if(void 0!==t)return t.exports;var l=o[n]={exports:{}};return e[n].call(l.exports,l,l.exports,r),l.exports}(390)})();