var __extends=this.__extends||function(b,c){function n(){this.constructor=b}for(var f in c)c.hasOwnProperty(f)&&(b[f]=c[f]);n.prototype=c.prototype;b.prototype=new n}; function JL(b){if(!b)return JL.__;Array.prototype.reduce||(Array.prototype.reduce=function(b,c){for(var l=c,k=0;kb.maxMessages)return!1;try{if(a.userAgentRegex&&!RegExp(a.userAgentRegex).test(navigator.userAgent))return!1}catch(d){}try{if(a.ipRegex&&b.clientIP&&!RegExp(a.ipRegex).test(b.clientIP))return!1}catch(s){}return!0}function f(a,d){try{if(a.disallow&&RegExp(a.disallow).test(d))return!1}catch(b){}return!0}function l(a){return"function"==typeof a?a instanceof RegExp?a.toString():a():a}function k(a){a=l(a);switch(typeof a){case "string":return new m(a,null,a);case "number":return a=a.toString(),new m(a,null,a);case "boolean":return a=a.toString(),new m(a,null,a);case "undefined":return new m("undefined",null,"undefined");case "object":return a instanceof RegExp||a instanceof String||a instanceof Number||a instanceof Boolean?(a=a.toString(),new m(a,null,a)):new m(null,a,JSON.stringify(a));default:return new m("unknown",null,"unknown")}}b.enabled;b.maxMessages; b.defaultAjaxUrl;b.clientIP;b.defaultBeforeSend;b.requestId="";var m=function(){return function(a,d,b){this.msg=a;this.meta=d;this.finalString=b}}();b.setOptions=function(a){c("enabled",a,this);c("maxMessages",a,this);c("defaultAjaxUrl",a,this);c("clientIP",a,this);c("requestId",a,this);c("defaultBeforeSend",a,this);return this};b.getAllLevel=function(){return-2147483648};b.getTraceLevel=function(){return 1E3};b.getDebugLevel=function(){return 2E3};b.getInfoLevel=function(){return 3E3};b.getWarnLevel= function(){return 4E3};b.getErrorLevel=function(){return 5E3};b.getFatalLevel=function(){return 6E3};b.getOffLevel=function(){return 2147483647};var h=function(){return function(a,d){this.inner=d;this.name="JL.Exception";this.message=k(a).finalString}}();b.Exception=h;h.prototype=Error();var r=function(){return function(a,d,b,c){this.l=a;this.m=d;this.n=b;this.t=c}}();b.LogItem=r;h=function(){function a(d,a){this.appenderName=d;this.sendLogItems=a;this.level=b.getTraceLevel();this.sendWithBufferLevel= 2147483647;this.storeInBufferLevel=-2147483648;this.bufferSize=0;this.batchSize=1;this.buffer=[];this.batchBuffer=[]}a.prototype.setOptions=function(a){c("level",a,this);c("ipRegex",a,this);c("userAgentRegex",a,this);c("disallow",a,this);c("sendWithBufferLevel",a,this);c("storeInBufferLevel",a,this);c("bufferSize",a,this);c("batchSize",a,this);this.bufferSizethis.bufferSize&&this.buffer.shift()):(e=this.batchSize&&this.sendBatch()))};a.prototype.sendBatch=function(){0==this.batchBuffer.length||null!=b.maxMessages&&1>b.maxMessages||(null!=b.maxMessages&&(b.maxMessages-=this.batchBuffer.length), this.sendLogItems(this.batchBuffer),this.batchBuffer.length=0)};return a}();b.Appender=h;var p=function(a){function d(b){a.call(this,b,d.prototype.sendLogItemsAjax)}__extends(d,a);d.prototype.setOptions=function(d){c("url",d,this);c("beforeSend",d,this);a.prototype.setOptions.call(this,d);return this};d.prototype.sendLogItemsAjax=function(a){try{var d="/jsnlog.logger";null!=b.defaultAjaxUrl&&(d=b.defaultAjaxUrl);this.url&&(d=this.url);var c=JSON.stringify({r:b.requestId,lg:a}),e=new XMLHttpRequest; e.open("POST",d);"function"===typeof this.beforeSend?this.beforeSend(e):"function"===typeof b.defaultBeforeSend&&b.defaultBeforeSend(e);e.setRequestHeader("Content-Type","application/json");e.setRequestHeader("JSNLog-RequestId",b.requestId);e.send(c)}catch(f){}};return d}(h);b.AjaxAppender=p;var q=function(a){function d(b){a.call(this,b,d.prototype.sendLogItemsConsole)}__extends(d,a);d.prototype.clog=function(a){console.log(a)};d.prototype.cerror=function(a){console.error?console.error(a):this.clog(a)}; d.prototype.cwarn=function(a){console.warn?console.warn(a):this.clog(a)};d.prototype.cinfo=function(a){console.info?console.info(a):this.clog(a)};d.prototype.cdebug=function(a){console.debug?console.debug(a):this.cinfo(a)};d.prototype.sendLogItemsConsole=function(a){try{if(console){var d;for(d=0;d=this.level&&n(this)&&(c?(g=this.buildExceptionObject(c),g.logData=l(b)):g=b,b=k(g),f(this,b.finalString))){if(this.onceOnly)for(g=this.onceOnly.length-1;0<=g;){if(RegExp(this.onceOnly[g]).test(b.finalString)){if(this.seenRegexes[g])return this;this.seenRegexes[g]=!0}g--}b.meta=b.meta||{};b.meta.loggerName=this.loggerName;for(g=this.appenders.length-1;0<=g;)this.appenders[g].log(1E3>= a?"trace":2E3>=a?"debug":3E3>=a?"info":4E3>=a?"warn":5E3>=a?"error":"fatal",b.msg,b.meta,function(){},a,b.finalString,this.loggerName),g--}return this};a.prototype.trace=function(a){return this.log(1E3,a)};a.prototype.debug=function(a){return this.log(2E3,a)};a.prototype.info=function(a){return this.log(3E3,a)};a.prototype.warn=function(a){return this.log(4E3,a)};a.prototype.error=function(a){return this.log(5E3,a)};a.prototype.fatal=function(a){return this.log(6E3,a)};a.prototype.fatalException= function(a,b){return this.log(6E3,a,b)};return a}();b.Logger=h;b.createAjaxAppender=function(a){return new p(a)};b.createConsoleAppender=function(a){return new q(a)};h=new p("");"undefined"===typeof window&&(h=new q(""));b.__=new b.Logger("");b.__.setOptions({level:b.getDebugLevel(),appenders:[h]})})(JL||(JL={}));var exports;"undefined"!==typeof exports&&(exports.JL=JL);var define;"function"==typeof define&&define.amd&&define("jsnlog",[],function(){return JL}); "function"==typeof __jsnlog_configure&&__jsnlog_configure(JL);