-
Notifications
You must be signed in to change notification settings - Fork 3
/
logatim.umd.min.js
1 lines (1 loc) · 5.56 KB
/
logatim.umd.min.js
1
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.logatim=n():e.logatim=n()}(this,function(){return function(e){function n(t){if(o[t])return o[t].exports;var r=o[t]={exports:{},id:t,loaded:!1};return e[t].call(r.exports,r,r.exports,n),r.loaded=!0,r.exports}var o={};return n.m=e,n.c=o,n.p="",n(0)}([function(e,n,o){"use strict";e.exports=o(4)()},function(e,n){"use strict";var o=e.exports={};o.DEFAULT_LEVEL=3,o.EOL="[49m[0m",o.LEVELS={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},o.LEVELS_KEYS=Object.keys(o.LEVELS),o.STORAGE_KEY="logatimLevel",o.STYLES={bold:{ansi:"[1m",css:"font-weight: 900"},dim:{ansi:"[2m",css:"opacity: .8"},italic:{ansi:"[3m",css:"font-style: italic"},underline:{ansi:"[4m",css:"text-decoration: underline"},blink:{ansi:"[5m",css:"text-decoration: blink"},inverse:{ansi:"[7m",css:"-moz-filter: invert(100%); -webkit-filter: invert(100%); filter: invert(100%)"},hidden:{ansi:"[8m",css:"visibility: hidden"},strikethrough:{ansi:"[9m",css:"text-decoration: line-through"},black:{ansi:"[30m",css:"color: #333"},red:{ansi:"[31m",css:"color: #e74c3c"},green:{ansi:"[32m",css:"color: #2ecc71"},yellow:{ansi:"[33m",css:"color: #f1c40f"},blue:{ansi:"[34m",css:"color: #3498db"},magenta:{ansi:"[35m",css:"color: #8e44ad"},cyan:{ansi:"[36m",css:"color: #00FFFF"},white:{ansi:"[37m",css:"color: #fff"},gray:{ansi:"[90m",css:"color: #7f8c8d"},grey:{ansi:"[90m",css:"color: #7f8c8d"},bgBlack:{ansi:"[40m",css:"background-color: #333"},bgRed:{ansi:"[41m",css:"background-color: #e74c3c"},bgGreen:{ansi:"[42m",css:"background-color: #2ecc71"},bgYellow:{ansi:"[43m",css:"background-color: #f1c40f"},bgBlue:{ansi:"[44m",css:"background-color: #3498db"},bgMagenta:{ansi:"[45m",css:"background-color: #8e44ad"},bgCyan:{ansi:"[46m",css:"background-color: #00ffff"},bgWhite:{ansi:"[47m",css:"background-color: #fff"},bgGray:{ansi:"[47m",css:"background-color: #7f8c8d"},bgGrey:{ansi:"[47m",css:"background-color: #7f8c8d"}}},function(e,n){(function(n){"use strict";var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},t=e.exports={};t.isObject=function(e){return e&&"object"===("undefined"==typeof e?"undefined":o(e))},t.detectNode=function(){try{return"[object process]"===Object.prototype.toString.call(n.process)}catch(e){return!1}},t.consoleFallback=function(){for(var e=function(){},n=["assert","clear","count","debug","dir","dirxml","error","exception","group","groupCollapsed","groupEnd","info","log","markTimeline","profile","profileEnd","table","time","timeEnd","timeline","timelineEnd","timeStamp","trace","warn"],o=void 0,t=n.length,r=window.console=window.console||{};t--;)o=n[t],r[o]||(r[o]=e)}}).call(n,function(){return this}())},function(e,n,o){"use strict";var t=o(1),r=e.exports={};r.getLevel=function(e){return t.LEVELS_KEYS[e]},r.setLevel=function(e,n){if("string"==typeof e&&void 0!==t.LEVELS[e.toUpperCase()]&&(e=t.LEVELS[e.toUpperCase()]),"number"==typeof e&&e>=0&&e<=t.LEVELS.SILENT)return r.persistLevel(e,n),e;throw new Error("logatim.setLevel() called with invalid level: "+e)},r.persistLevel=function(e,n){var o=t.LEVELS_KEYS[e]||"SILENT",r=t.STORAGE_KEY;if(!n){try{window.localStorage[r]=o}catch(c){}try{window.document.cookie=encodeURIComponent(r)+"="+o+";"}catch(c){}}},r.getPersistedLevel=function(e){var n=void 0,o=t.STORAGE_KEY;try{n=window.localStorage[o]}catch(r){}if("undefined"==typeof n)try{var c=window.document.cookie,i=c.indexOf(encodeURIComponent(o)+"=");i&&(n=/^([^;]+)/.exec(c.slice(i))[1])}catch(r){}return void 0===t.LEVELS[n]&&(n=e),n}},function(e,n,o){"use strict";var t=o(1),r=o(3),c=o(5),i=o(2),s=o(2).detectNode(),a=t.DEFAULT_LEVEL;s||i.consoleFallback();var u=e.exports=function(e){e&&("function"==typeof e&&(e=e()),c.addChunk({key:"str",val:e}));var n=function(e){return u(e)};n.inspect=function(){},n.getLevel=function(){return r.getLevel(a)},n.setLevel=function(e){a=r.setLevel(e,s),n.raw=c.raw.bind(null,s),c.updateLogMethods(n,a,s)},n.setEnv=function(e){s="node"===e,n.raw=c.raw.bind(null,s),c.updateLogMethods(n,a,s)},Object.keys(t.STYLES).forEach(function(e){Object.defineProperty(n,e,{get:function(){return c.addChunk({key:"style",val:e}),u()}})}),n.raw=c.raw.bind(null,s);var o=s?r.getPersistedLevel(a):a;return n.setLevel(o),c.updateLogMethods(n,a,s),n}},function(e,n,o){"use strict";var t=o(1),r=o(2),c=[],i=function(){c=[]},s=function(e){return e.map(function(e){return"function"==typeof e&&(e=e()),e}).reduce(function(e,n){return r.isObject(n)&&(n=JSON.stringify(n)),(e+" "+n).trim()},"")},a=function(e,n){var o=Array.prototype.slice.call(arguments,2),t=u(o,n);return n?console[e](t):console[e].apply(console,t),i()},u=function(e,n){var o=s(e);return n?l([o]):f(o)},l=function(e){return c.reverse().forEach(function(n){var o=n.val;"style"===n.key&&(o=t.STYLES[o].ansi),e=[o].concat(e)}),""+e.join("")+t.EOL},f=function(e){var n=[],o=[],r=[];if(c.forEach(function(e,c){var i=e.val;"str"===e.key?(i="%c"+i,r.push(i),0!==o.length&&(n.push(o.join(";")),o=[])):"style"===e.key&&(i=t.STYLES[i].css,o.push(i))}),0!==o.length&&(n.push(o.join(";")),o=[]),e){var i=c[c.length-1];i&&"style"===i.key&&(e="%c"+e),r.push(e)}return[r.join("")].concat(n)},d=e.exports={};d.addChunk=function(e){return c.push(e)},d.raw=function(e,n){var o=u([n||""],e);return i(),o},d.updateLogMethods=function(e,n,o){t.LEVELS_KEYS.forEach(function(t,r){t=t.toLowerCase();var c=t;o&&"debug"===t&&(t="info"),r>=n?e[c]=a.bind(null,t,o):e[c]=function(){return i()}})}}])});