/* * JSNLog 2.24.0 * Open source under the MIT License. * Copyright 2016 Mattijs Perdeck All rights reserved. */ var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,e){a!=Array.prototype&&a!=Object.prototype&&(a[b]=e.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this); $jscomp.polyfill=function(a,b,e,f){if(b){e=$jscomp.global;a=a.split(".");for(f=0;fa.maxMessages)return!1;try{if(d.userAgentRegex&&!(new RegExp(d.userAgentRegex)).test(navigator.userAgent))return!1}catch(c){}try{if(d.ipRegex&&a.clientIP&&!(new RegExp(d.ipRegex)).test(a.clientIP))return!1}catch(c){}return!0}function f(a,c){try{if(a.disallow&&(new RegExp(a.disallow)).test(c))return!1}catch(g){}return!0}function k(a){return"function"== typeof a?a instanceof RegExp?a.toString():a():a}function n(d){d=k(d);switch(typeof d){case "string":return new l(d,null,d);case "number":var c=d.toString();return new l(c,null,c);case "boolean":return c=d.toString(),new l(c,null,c);case "undefined":return new l("undefined",null,"undefined");case "object":if(d instanceof RegExp||d instanceof String||d instanceof Number||d instanceof Boolean)return c=d.toString(),new l(c,null,c);c="function"===typeof a.serialize?a.serialize.call(this,d):JSON.stringify(d); return new l(null,d,c);default:return new l("unknown",null,"unknown")}}a.requestId="";var l=function(){return function(a,c,g){this.msg=a;this.meta=c;this.finalString=g}}();a.setOptions=function(a){b("enabled",a,this);b("maxMessages",a,this);b("defaultAjaxUrl",a,this);b("clientIP",a,this);b("requestId",a,this);b("defaultBeforeSend",a,this);b("serialize",a,this);return this};a.getAllLevel=function(){return-2147483648};a.getTraceLevel=function(){return 1E3};a.getDebugLevel=function(){return 2E3};a.getInfoLevel= function(){return 3E3};a.getWarnLevel=function(){return 4E3};a.getErrorLevel=function(){return 5E3};a.getFatalLevel=function(){return 6E3};a.getOffLevel=function(){return 2147483647};var h=function(){return function(a,c){this.inner=c;this.name="JL.Exception";this.message=n(a).finalString}}();a.Exception=h;h.prototype=Error();var r=function(){return function(a,c,g,b){this.l=a;this.m=c;this.n=g;this.t=b}}();a.LogItem=r;h=function(){function d(c,g){this.appenderName=c;this.sendLogItems=g;this.level= a.getTraceLevel();this.sendWithBufferLevel=2147483647;this.storeInBufferLevel=-2147483648;this.bufferSize=0;this.batchSize=1;this.batchTimeout=2147483647;this.buffer=[];this.batchBuffer=[];this.batchTimeoutTimer=null}d.prototype.clearTimeoutTimer=function(){this.batchTimeoutTimer&&(clearTimeout(this.batchTimeoutTimer),this.batchTimeoutTimer=null)};d.prototype.addLogItemToBuffer=function(a){this.batchBuffer.push(a);var c=this;this.batchTimeoutTimer||(this.batchTimeoutTimer=setTimeout(function(){c.sendBatch.call(c)}, this.batchTimeout))};d.prototype.setOptions=function(a){b("level",a,this);b("ipRegex",a,this);b("userAgentRegex",a,this);b("disallow",a,this);b("sendWithBufferLevel",a,this);b("storeInBufferLevel",a,this);b("bufferSize",a,this);b("batchSize",a,this);b("batchTimeout",a,this);this.bufferSizethis.bufferSize&&this.buffer.shift()):(m=this.batchSize&&this.sendBatch()))};d.prototype.sendBatch=function(){this.clearTimeoutTimer();0==this.batchBuffer.length||null!=a.maxMessages&&1>a.maxMessages||(null!=a.maxMessages&&(a.maxMessages-=this.batchBuffer.length),this.sendLogItems(this.batchBuffer), this.batchBuffer.length=0)};return d}();a.Appender=h;var p=function(d){function c(a){return d.call(this,a,c.prototype.sendLogItemsAjax)||this}__extends(c,d);c.prototype.setOptions=function(a){b("url",a,this);b("beforeSend",a,this);d.prototype.setOptions.call(this,a);return this};c.prototype.sendLogItemsAjax=function(c){try{var b="/jsnlog.logger";null!=a.defaultAjaxUrl&&(b=a.defaultAjaxUrl);this.url&&(b=this.url);var g=this.getXhr(b),d={r:a.requestId,lg:c};"function"===typeof this.beforeSend?this.beforeSend.call(this, g,d):"function"===typeof a.defaultBeforeSend&&a.defaultBeforeSend.call(this,g,d);var e=JSON.stringify(d);g.send(e)}catch(u){}};c.prototype.getXhr=function(c){var b=new XMLHttpRequest;if(!("withCredentials"in b)&&"undefined"!=typeof XDomainRequest)return b=new XDomainRequest,b.open("POST",c),b;b.open("POST",c);b.setRequestHeader("Content-Type","application/json");b.setRequestHeader("JSNLog-RequestId",a.requestId);return b};return c}(h);a.AjaxAppender=p;var q=function(b){function c(a){return b.call(this, a,c.prototype.sendLogItemsConsole)||this}__extends(c,b);c.prototype.clog=function(a){console.log(a)};c.prototype.cerror=function(a){console.error?console.error(a):this.clog(a)};c.prototype.cwarn=function(a){console.warn?console.warn(a):this.clog(a)};c.prototype.cinfo=function(a){console.info?console.info(a):this.clog(a)};c.prototype.cdebug=function(a){console.debug?console.debug(a):this.cinfo(a)};c.prototype.sendLogItemsConsole=function(c){try{if(console){var b;for(b=0;b=this.level&&e(this)&&(d?(c=this.buildExceptionObject(d),c.logData=k(b)):c=b,b=n(c),f(this,b.finalString))){if(this.onceOnly)for(c=this.onceOnly.length-1;0<=c;){if((new RegExp(this.onceOnly[c])).test(b.finalString)){if(this.seenRegexes[c])return this; this.seenRegexes[c]=!0}c--}b.meta=b.meta||{};b.meta.loggerName=this.loggerName;for(c=this.appenders.length-1;0<=c;)this.appenders[c].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),c--}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}();a.Logger=h;a.createAjaxAppender=function(a){return new p(a)};a.createConsoleAppender=function(a){return new q(a)};h=new p("");"undefined"===typeof window&&(h=new q(""));a.__=new a.Logger("");a.__.setOptions({level:a.getDebugLevel(),appenders:[h]})})(JL||(JL={}));"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);"undefined"===typeof window||window.onerror||(window.onerror=function(a,b,e,f,k){JL("onerrorLogger").fatalException({msg:"Uncaught Exception",errorMsg:a,url:b,"line number":e,column:f},k);return!1}); "undefined"===typeof window||window.onunhandledrejection||(window.onunhandledrejection=function(a){JL("onerrorLogger").fatalException({msg:"unhandledrejection",errorMsg:a.reason?a.reason.message:null},a.reason);return!1});