|
1 |
- !function(e,t){"function"==typeof define&&define.amd?define(t):"object"==typeof module&&module.exports?module.exports=t():e.prefix=t(e)}(this,function(e){"use strict";var n,t,a={template:"[%t] %l:",levelFormatter:function(e){return e.toUpperCase()},nameFormatter:function(e){return e||"root"},timestampFormatter:function(e){return e.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1")},format:void 0},d={},r={reg:function(e){if(!e||!e.getLogger)throw new TypeError("Argument is not a root logger");n=e},apply:function(e,t){if(!e||!e.setLevel)throw new TypeError("Argument is not a logger");var r=e.methodFactory,s=e.name||"",o=d[s]||d[""]||a;return d[s]||(e.methodFactory=function(i,e,f){var p=r(i,e,f),m=d[f]||d[""],u=-1!==m.template.indexOf("%t"),c=-1!==m.template.indexOf("%l"),g=-1!==m.template.indexOf("%n");return function(){for(var e="",t=arguments.length,r=Array(t),o=0;o<t;o++)r[o]=arguments[o];if(s||!d[f]){var n=m.timestampFormatter(new Date),a=m.levelFormatter(i),l=m.nameFormatter(f);m.format?e+=m.format(a,l,n):(e+=m.template,u&&(e=e.replace(/%t/,n)),c&&(e=e.replace(/%l/,a)),g&&(e=e.replace(/%n/,l))),r.length&&"string"==typeof r[0]?r[0]=e+" "+r[0]:r.unshift(e)}p.apply(void 0,r)}}),(t=t||{}).template&&(t.format=void 0),d[s]=function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(t in arguments[r])Object.prototype.hasOwnProperty.call(arguments[r],t)&&(e[t]=arguments[r][t]);return e}({},o,t),e.setLevel(e.getLevel()),n||e.warn("It is necessary to call the function reg() of loglevel-plugin-prefix before calling apply. From the next release, it will throw an error. See more: https://github.com/kutuluk/loglevel-plugin-prefix/blob/master/README.md"),e}};return e&&(t=e.prefix,r.noConflict=function(){return e.prefix===r&&(e.prefix=t),r}),r});
|