-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathangular-splunk-logger.min.js
2 lines (2 loc) · 3.38 KB
/
angular-splunk-logger.min.js
1
2
!function(a){"use strict";a.module("splunkLogger.logger",[]).provider("SplunkLogger",function(){function b(b){return a.isDefined(b)?(H=b,s):H}function c(b){return a.isDefined(b)?(G=b,s):G}function d(b){return a.isDefined(b)?(D=b,s):D}function e(b){return a.isDefined(b)?(u=b,s):u}function f(b){return a.isObject(b)?(C=b,s):C}function g(b){return a.isDefined(b)?(v=!!b,s):v}function h(b){return a.isDefined(b)?(w=!!b,s):w}function i(b){return a.isDefined(b)?(x=!!b,s):x}function j(b){return a.isDefined(b)?(y=b,s):y}function k(b){return a.isDefined(b)?(z=!!b,s):z}function l(b){if(a.isDefined(b)){var c=t.indexOf(b.toUpperCase());if(c<0)throw"Invalid logging level specified: "+b;return F=c,s}return t[F]}function m(a){return t.indexOf(a.toUpperCase())>=F}function n(b){return a.isDefined(b)?(B=!!b,s):B}function o(b){return a.isDefined(b)?(A=!!b,s):A}function p(b){return a.isDefined(b)?(E=b,I=null===E?q:r(),s):E}function q(a,b,c,d){a.post(b,c,d)}function r(){var a=0;return function(b,c,d,e){a<E&&b.post(c,d,e).then(function(){a=0},function(){++a})}}var s=this,t=["DEBUG","INFO","WARN","ERROR"],u={},v=!1,w=!1,x=!1,y=null,z=!1,A=!0,B=!0,C={},D=null,E=null,F=0,G=null,H=null,I=q;this.endpoint=b,this.token=c,this.source=d,this.errorThreshold=p,this.fields=e,this.labels=f,this.includeUrl=g,this.includeTimestamp=h,this.includeUserAgent=i,this.inputTag=j,this.sendConsoleErrors=k,this.level=l,this.loggingEnabled=n,this.isLevelEnabled=m,this.logToConsole=o,this.$get=["$injector",function(d){var f=null,g=function(b){function c(b){var c=d.get("$window"),e=d.get("$location"),g={};D&&(g.source=D),w&&(g.time=f.getTime()/1e3);var h=a.extend({},u,b);v&&(h.url=e.absUrl()),x&&(h.userAgent=c.navigator.userAgent);for(var i in C)i in h&&(h[C[i]]=h[i],delete h[i]);return g.event=h,g}if(G&&H&&B){var e=d.get("$http");f=new Date;var g=c(b),h={headers:{Authorization:"Splunk "+G,"Cache-Control":void 0,"Content-Type":void 0},responseType:"json",withCredentials:!0};I(e,H,g,h)}};return{lastLog:function(){return f},sendConsoleErrors:function(){return z},level:function(){return F},loggingEnabled:n,isLevelEnabled:m,sendMessage:g,logToConsole:o,token:c,endpoint:b,fields:e}}]}),a.module("splunkLogger",["splunkLogger.logger"]).config(["$provide",function(b){b.decorator("$log",["$delegate","$injector",function(b,c){var d=c.get("SplunkLogger");if(d.sendConsoleErrors()===!0){var e=window.onerror;window.onerror=function(a,b,c,f,g){d.sendMessage({level:"ERROR",message:a,line:c,col:f,stack:g&&g.stack}),e&&"function"==typeof e&&e.apply(window,arguments)}}var f=function(b,c,e){var f=function(){var f=Array.prototype.slice.call(arguments);if(d.logToConsole()&&b.apply(null,f),d.loggingEnabled()&&d.isLevelEnabled(c)){var g=(1===f.length?f[0]:f)||{},h={level:c};if(a.isDefined(g.stack)||a.isDefined(g[0])&&a.isDefined(g[0].stack)){if(d.sendConsoleErrors()!==!0)return;h.message=g.message||g[0].message,h.stack=g.stack||g[0].stack}else a.isObject(g)?h=a.extend({},g,h):h.message=g;e&&(h.logger=g),d.sendMessage(h)}};return f.logs=[],f},g=function(a){return{log:a.log,info:a.info,warn:a.warn,error:a.error}}(b),h=function(a){return{log:f(g.log,"INFO",a),debug:f(g.debug,"DEBUG",a),info:f(g.info,"INFO",a),warn:f(g.warn,"WARN",a),error:f(g.error,"ERROR",a)}};return b.log=f(b.log,"INFO"),b.debug=f(b.debug,"DEBUG"),b.info=f(b.info,"INFO"),b.warn=f(b.warn,"WARN"),b.error=f(b.error,"ERROR"),b.getLogger=h,b}])}])}(window.angular);
//# sourceMappingURL=angular-splunk-logger.min.map