advanced-logger
Version:
Advanced logger module extendable with plugins. Works in nodejs and browsers
2 lines • 29.3 kB
JavaScript
window.advancedLogger=function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=8)}([function(t,e,r){"use strict";var n,o="object"==typeof Reflect?Reflect:null,i=o&&"function"==typeof o.apply?o.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};n=o&&"function"==typeof o.ownKeys?o.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var s=Number.isNaN||function(t){return t!=t};function u(){u.init.call(this)}t.exports=u,u.EventEmitter=u,u.prototype._events=void 0,u.prototype._eventsCount=0,u.prototype._maxListeners=void 0;var a=10;function f(t){return void 0===t._maxListeners?u.defaultMaxListeners:t._maxListeners}function c(t,e,r,n){var o,i,s,u;if("function"!=typeof r)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r);if(void 0===(i=t._events)?(i=t._events=Object.create(null),t._eventsCount=0):(void 0!==i.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),i=t._events),s=i[e]),void 0===s)s=i[e]=r,++t._eventsCount;else if("function"==typeof s?s=i[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(o=f(t))>0&&s.length>o&&!s.warned){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=s.length,u=a,console&&console.warn&&console.warn(u)}return t}function l(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},o=function(){for(var t=[],e=0;e<arguments.length;e++)t.push(arguments[e]);this.fired||(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,i(this.listener,this.target,t))}.bind(n);return o.listener=r,n.wrapFn=o,o}function p(t,e,r){var n=t._events;if(void 0===n)return[];var o=n[e];return void 0===o?[]:"function"==typeof o?r?[o.listener||o]:[o]:r?function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(o):d(o,o.length)}function h(t){var e=this._events;if(void 0!==e){var r=e[t];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function d(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}Object.defineProperty(u,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(t){if("number"!=typeof t||t<0||s(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");a=t}}),u.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},u.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||s(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},u.prototype.getMaxListeners=function(){return f(this)},u.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var n="error"===t,o=this._events;if(void 0!==o)n=n&&void 0===o.error;else if(!n)return!1;if(n){var s;if(e.length>0&&(s=e[0]),s instanceof Error)throw s;var u=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw u.context=s,u}var a=o[t];if(void 0===a)return!1;if("function"==typeof a)i(a,this,e);else{var f=a.length,c=d(a,f);for(r=0;r<f;++r)i(c[r],this,e)}return!0},u.prototype.addListener=function(t,e){return c(this,t,e,!1)},u.prototype.on=u.prototype.addListener,u.prototype.prependListener=function(t,e){return c(this,t,e,!0)},u.prototype.once=function(t,e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e);return this.on(t,l(this,t,e)),this},u.prototype.prependOnceListener=function(t,e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e);return this.prependListener(t,l(this,t,e)),this},u.prototype.removeListener=function(t,e){var r,n,o,i,s;if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e);if(void 0===(n=this._events))return this;if(void 0===(r=n[t]))return this;if(r===e||r.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete n[t],n.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(o=-1,i=r.length-1;i>=0;i--)if(r[i]===e||r[i].listener===e){s=r[i].listener,o=i;break}if(o<0)return this;0===o?r.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(r,o),1===r.length&&(n[t]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",t,s||e)}return this},u.prototype.off=u.prototype.removeListener,u.prototype.removeAllListeners=function(t){var e,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[t]),this;if(0===arguments.length){var o,i=Object.keys(r);for(n=0;n<i.length;++n)"removeListener"!==(o=i[n])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=r[t]))this.removeListener(t,e);else if(void 0!==e)for(n=e.length-1;n>=0;n--)this.removeListener(t,e[n]);return this},u.prototype.listeners=function(t){return p(this,t,!0)},u.prototype.rawListeners=function(t){return p(this,t,!1)},u.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):h.call(t,e)},u.prototype.listenerCount=h,u.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(t,e){t.exports=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(23),o=r(24),i=r(7),s=function(){function t(t){this.serviceConfig=t.serviceConfig,this.defaultLogConfig=t.defaultLogConfig||{},t.serializer&&(this.serializer=t.serializer)}return t.prototype.serializer=function(t){return i.default.tryJSONStringify(t)||n.default(t)},t.prototype.sendAllLogs=function(t){var e=this;return this.preparePayload(t).then(function(t){var r=e.getHeaders();return e.serviceConfig.retryAttempts&&e.serviceConfig.retryAttempts>0?o.default.postRequest(e.serviceConfig,r,t).catch(function(){return o.default.delayedRetry(e.serviceConfig.retryAttempts,e.serviceConfig.retryInterval,o.default.postRequest.bind(e,e.serviceConfig,r,t))}):o.default.postRequest(e.serviceConfig,r,t)})},t.prototype.preparePayload=function(t){var e=this,r=t.map(function(t){return e.serializer(Object.assign({},e.defaultLogConfig,t))});return Promise.resolve(r.join("\n"))},t.prototype.destroy=function(){this.serviceConfig=null,this.defaultLogConfig=null},t.prototype.getHeaders=function(){return{}},t}();e.default=s},function(t,e,r){var n=r(1),o=r(12),i=r(15),s="Expected a function",u=Math.max,a=Math.min;t.exports=function(t,e,r){var f,c,l,p,h,d,y=0,v=!1,g=!1,m=!0;if("function"!=typeof t)throw new TypeError(s);function b(e){var r=f,n=c;return f=c=void 0,y=e,p=t.apply(n,r)}function _(t){var r=t-d;return void 0===d||r>=e||r<0||g&&t-y>=l}function E(){var t=o();if(_(t))return w(t);h=setTimeout(E,function(t){var r=e-(t-d);return g?a(r,l-(t-y)):r}(t))}function w(t){return h=void 0,m&&f?b(t):(f=c=void 0,p)}function O(){var t=o(),r=_(t);if(f=arguments,c=this,d=t,r){if(void 0===h)return function(t){return y=t,h=setTimeout(E,e),v?b(t):p}(d);if(g)return h=setTimeout(E,e),b(d)}return void 0===h&&(h=setTimeout(E,e)),p}return e=i(e)||0,n(r)&&(v=!!r.leading,l=(g="maxWait"in r)?u(i(r.maxWait)||0,e):l,m="trailing"in r?!!r.trailing:m),O.cancel=function(){void 0!==h&&clearTimeout(h),y=0,f=d=c=h=void 0},O.flush=function(){return void 0===h?p:w(o())},O}},function(t,e,r){var n=r(13),o="object"==typeof self&&self&&self.Object===Object&&self,i=n||o||Function("return this")();t.exports=i},function(t,e,r){var n=r(4).Symbol;t.exports=n},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),function(t){t[t.RAPID_FIRE_GROUPING=0]="RAPID_FIRE_GROUPING"}(e.TransformationEnum||(e.TransformationEnum={}))},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default={getLogIdByFields:function(t,e){return e.map(function(e){return e+"-"+t[e]}).join("-")},tryJSONStringify:function(t){try{return JSON.stringify(t)}catch(t){return""}}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(9);e.AdvancedLogger=n.default;var o=r(6);e.TransformationEnum=o.TransformationEnum;var i=r(21),s=r(22),u=r(27),a=r(28),f=r(29),c=r(30),l=r(31),p=r(32),h={InstantStrategy:f.default,OnBundleSizeStrategy:c.default,OnRequestStrategy:p.default,OnIntervalStrategy:l.default};e.strategy=h;var d={SumologicService:u.default,LogglyService:s.default,ConsoleService:i.default,ElasticsearchService:a.default};e.service=d},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(10),o=function(){function t(t){this.configuration=t,this.logStore=new n.default({transformations:this.configuration.transformations}),this.strategy=this.configuration.strategy,this.service=this.configuration.service,this.logStore.eventEmitter.on("add",this.onAdd.bind(this)),this.logStore.eventEmitter.on("clear",this.onClear.bind(this)),this.logStore.eventEmitter.on("error",this.onStoreError.bind(this)),this.strategy.eventEmitter.on("send",this.onSend.bind(this)),this.strategy.eventEmitter.on("error",this.onStrategyError.bind(this))}return t.prototype.log=function(t){this.logStore.add(t)},t.prototype.sendAllLogs=function(){this.strategy.sendAll()},t.prototype.destroy=function(){this.logStore.destroy(),this.logStore=null,this.strategy.destroy(),this.strategy=null,this.service.destroy(),this.service=null,this.configuration=null},t.prototype.onStoreError=function(t){console.error(t)},t.prototype.onAdd=function(t){this.strategy.onAdd(t)},t.prototype.onClear=function(t){this.strategy.onClear()},t.prototype.onStrategyError=function(t){console.error(t)},t.prototype.onSend=function(){if(this.logStore.size()>0){var t=this.logStore.getAll();this.logStore.clear(),this.service.sendAllLogs(t).catch(function(t){return console.error(t)})}},t}();e.default=o},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(11),o=r(0),i=r(6),s=r(7),u=function(){function t(t){this.groupLeftIndex=-1,this.logs=[],this.eventEmitter=new o.EventEmitter,this.config=t,this.initTransformations()}return t.prototype.add=function(t){if(this.groupableConfig){var e=s.default.getLogIdByFields(t,this.groupableConfig.groupIdentityFields);this.identityMap.has(e)||this.logs.push(t),this.onAddToGroup(t)}else this.logs.push(t);this.eventEmitter.emit("add",{logCount:this.size()})},t.prototype.clear=function(){this.logs.length=0,this.eventEmitter.emit("clear",null)},t.prototype.getAll=function(){return this.throttledOnGroupFinalize&&this.throttledOnGroupFinalize.flush(),this.logs.slice()},t.prototype.size=function(){return this.logs.length},t.prototype.destroy=function(){this.throttledOnGroupFinalize&&this.throttledOnGroupFinalize.cancel(),this.logs.length=0,this.eventEmitter.removeAllListeners(),this.eventEmitter=null},t.prototype.initTransformations=function(){if(this.config.transformations){var t=this.config.transformations.find(function(t){return t.type===i.TransformationEnum.RAPID_FIRE_GROUPING});t&&(this.groupableConfig=t.configuration,this.identityMap=new Map,this.throttledOnGroupFinalize=n(this.onGroupFinalize.bind(this),this.groupableConfig.interval,{trailing:!0,leading:!1}),this.eventEmitter.on("add",this.throttledOnGroupFinalize))}},t.prototype.onAddToGroup=function(t){var e=s.default.getLogIdByFields(t,this.groupableConfig.groupIdentityFields);if(this.identityMap.has(e)){var r=this.identityMap.get(e);this.identityMap.set(e,r+1)}else this.identityMap.set(e,1)},t.prototype.onGroupFinalize=function(){var t=this.logs.length;if(t>0)for(var e=-1!==this.groupLeftIndex?this.groupLeftIndex:0;e<t;e++){var r=this.logs[e],n=s.default.getLogIdByFields(r,this.groupableConfig.groupIdentityFields);r[this.groupableConfig.groupFieldName]=this.identityMap.has(n)?this.identityMap.get(n):1}this.groupLeftIndex=t>0?t-1:-1,this.identityMap.clear()},t}();e.default=u},function(t,e,r){var n=r(3),o=r(1),i="Expected a function";t.exports=function(t,e,r){var s=!0,u=!0;if("function"!=typeof t)throw new TypeError(i);return o(r)&&(s="leading"in r?!!r.leading:s,u="trailing"in r?!!r.trailing:u),n(t,e,{leading:s,maxWait:e,trailing:u})}},function(t,e,r){var n=r(4);t.exports=function(){return n.Date.now()}},function(t,e,r){(function(e){var r="object"==typeof e&&e&&e.Object===Object&&e;t.exports=r}).call(this,r(14))},function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e,r){var n=r(1),o=r(16),i=NaN,s=/^\s+|\s+$/g,u=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,f=/^0o[0-7]+$/i,c=parseInt;t.exports=function(t){if("number"==typeof t)return t;if(o(t))return i;if(n(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=n(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(s,"");var r=a.test(t);return r||f.test(t)?c(t.slice(2),r?2:8):u.test(t)?i:+t}},function(t,e,r){var n=r(17),o=r(20),i="[object Symbol]";t.exports=function(t){return"symbol"==typeof t||o(t)&&n(t)==i}},function(t,e,r){var n=r(5),o=r(18),i=r(19),s="[object Null]",u="[object Undefined]",a=n?n.toStringTag:void 0;t.exports=function(t){return null==t?void 0===t?u:s:a&&a in Object(t)?o(t):i(t)}},function(t,e,r){var n=r(5),o=Object.prototype,i=o.hasOwnProperty,s=o.toString,u=n?n.toStringTag:void 0;t.exports=function(t){var e=i.call(t,u),r=t[u];try{t[u]=void 0;var n=!0}catch(t){}var o=s.call(t);return n&&(e?t[u]=r:delete t[u]),o}},function(t,e){var r=Object.prototype.toString;t.exports=function(t){return r.call(t)}},function(t,e){t.exports=function(t){return null!=t&&"object"==typeof t}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(){}return t.prototype.preparePayload=function(t){var e=this;return Promise.resolve(t.map(function(t){return e.serializer(t)}))},t.prototype.sendAllLogs=function(t){return console.log(t),Promise.resolve()},t.prototype.destroy=function(){},t.prototype.serializer=function(t){return t},t}();e.default=n},function(t,e,r){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0});var i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.getHeaders=function(){return{"Content-Type":"text/plain"}},e}(r(2).default);e.default=i},function(t,e){t.exports=n,n.default=n,n.stable=i,n.stableStringify=i;var r=[];function n(t,e,n){!function t(e,n,o,i){var s;if("object"==typeof e&&null!==e){for(s=0;s<o.length;s++)if(o[s]===e)return i[n]="[Circular]",void r.push([i,n,e]);if(o.push(e),Array.isArray(e))for(s=0;s<e.length;s++)t(e[s],s,o,e);else{var u=Object.keys(e);for(s=0;s<u.length;s++){var a=u[s];t(e[a],a,o,e)}}o.pop()}}(t,"",[],void 0);for(var o=JSON.stringify(t,e,n);0!==r.length;){var i=r.pop();i[0][i[1]]=i[2]}return o}function o(t,e){return t<e?-1:t>e?1:0}function i(t,e,n){for(var i=function t(e,n,i,s){var u;if("object"==typeof e&&null!==e){for(u=0;u<i.length;u++)if(i[u]===e)return s[n]="[Circular]",void r.push([s,n,e]);if("function"==typeof e.toJSON)return;if(i.push(e),Array.isArray(e))for(u=0;u<e.length;u++)t(e[u],u,i,e);else{var a={},f=Object.keys(e).sort(o);for(u=0;u<f.length;u++){var c=f[u];t(e[c],c,i,e),a[c]=e[c]}if(void 0===s)return a;r.push([s,n,e]),s[n]=a}i.pop()}}(t,"",[],void 0)||t,s=JSON.stringify(i,e,n);0!==r.length;){var u=r.pop();u[0][u[1]]=u[2]}return s}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(25),o={postRequest:function(t,e,r){return n(t.url,{method:t.method,body:r,headers:e})},delayedRetry:function(t,e,r){return void 0===e&&(e=0),new Promise(function(t,n){setTimeout(function(){return r().then(t).catch(n)},e)}).catch(function(n){return t>1?o.delayedRetry(t-1,e,r):Promise.reject(n)})}};e.default=o},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(26);t.exports=window.fetch||n.fetch},function(t,e,r){!function(t){"use strict";var e={searchParams:"URLSearchParams"in self,iterable:"Symbol"in self&&"iterator"in Symbol,blob:"FileReader"in self&&"Blob"in self&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in self,arrayBuffer:"ArrayBuffer"in self};if(e.arrayBuffer)var r=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],n=ArrayBuffer.isView||function(t){return t&&r.indexOf(Object.prototype.toString.call(t))>-1};function o(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function i(t){return"string"!=typeof t&&(t=String(t)),t}function s(t){var r={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return e.iterable&&(r[Symbol.iterator]=function(){return r}),r}function u(t){this.map={},t instanceof u?t.forEach(function(t,e){this.append(e,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function a(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function f(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function c(t){var e=new FileReader,r=f(e);return e.readAsArrayBuffer(t),r}function l(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function p(){return this.bodyUsed=!1,this._initBody=function(t){var r;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:e.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:e.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:e.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():e.arrayBuffer&&e.blob&&(r=t)&&DataView.prototype.isPrototypeOf(r)?(this._bodyArrayBuffer=l(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):e.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||n(t))?this._bodyArrayBuffer=l(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):e.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},e.blob&&(this.blob=function(){var t=a(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?a(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(c)}),this.text=function(){var t,e,r,n=a(this);if(n)return n;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=f(e),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},e.formData&&(this.formData=function(){return this.text().then(y)}),this.json=function(){return this.text().then(JSON.parse)},this}u.prototype.append=function(t,e){t=o(t),e=i(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},u.prototype.delete=function(t){delete this.map[o(t)]},u.prototype.get=function(t){return t=o(t),this.has(t)?this.map[t]:null},u.prototype.has=function(t){return this.map.hasOwnProperty(o(t))},u.prototype.set=function(t,e){this.map[o(t)]=i(e)},u.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},u.prototype.keys=function(){var t=[];return this.forEach(function(e,r){t.push(r)}),s(t)},u.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),s(t)},u.prototype.entries=function(){var t=[];return this.forEach(function(e,r){t.push([r,e])}),s(t)},e.iterable&&(u.prototype[Symbol.iterator]=u.prototype.entries);var h=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function d(t,e){var r,n,o=(e=e||{}).body;if(t instanceof d){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new u(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,o||null==t._bodyInit||(o=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new u(e.headers)),this.method=(r=e.method||this.method||"GET",n=r.toUpperCase(),h.indexOf(n)>-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&o)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(o)}function y(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),o=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(o))}}),e}function v(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new u(e.headers),this.url=e.url||"",this._initBody(t)}d.prototype.clone=function(){return new d(this,{body:this._bodyInit})},p.call(d.prototype),p.call(v.prototype),v.prototype.clone=function(){return new v(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new u(this.headers),url:this.url})},v.error=function(){var t=new v(null,{status:0,statusText:""});return t.type="error",t};var g=[301,302,303,307,308];v.redirect=function(t,e){if(-1===g.indexOf(e))throw new RangeError("Invalid status code");return new v(null,{status:e,headers:{location:t}})},t.DOMException=self.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function m(r,n){return new Promise(function(o,i){var s=new d(r,n);if(s.signal&&s.signal.aborted)return i(new t.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function f(){a.abort()}a.onload=function(){var t,e,r={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",e=new u,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(t){var r=t.split(":"),n=r.shift().trim();if(n){var o=r.join(":").trim();e.append(n,o)}}),e)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var n="response"in a?a.response:a.responseText;o(new v(n,r))},a.onerror=function(){i(new TypeError("Network request failed"))},a.ontimeout=function(){i(new TypeError("Network request failed"))},a.onabort=function(){i(new t.DOMException("Aborted","AbortError"))},a.open(s.method,s.url,!0),"include"===s.credentials?a.withCredentials=!0:"omit"===s.credentials&&(a.withCredentials=!1),"responseType"in a&&e.blob&&(a.responseType="blob"),s.headers.forEach(function(t,e){a.setRequestHeader(e,t)}),s.signal&&(s.signal.addEventListener("abort",f),a.onreadystatechange=function(){4===a.readyState&&s.signal.removeEventListener("abort",f)}),a.send(void 0===s._bodyInit?null:s._bodyInit)})}m.polyfill=!0,self.fetch||(self.fetch=m,self.Headers=u,self.Request=d,self.Response=v),t.Headers=u,t.Request=d,t.Response=v,t.fetch=m,Object.defineProperty(t,"__esModule",{value:!0})}(e)},function(t,e,r){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0});var i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.getHeaders=function(){var t=this.serviceConfig;return{"Content-Type":"application/json","X-Sumo-Category":t.sourceCategory,"X-Sumo-Host":t.host,"X-Sumo-Name":t.sourceName}},e}(r(2).default);e.default=i},function(t,e,r){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0});var i=r(2),s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.preparePayload=function(t){var e=this,r=[];return t.forEach(function(t){var n=Object.assign({},e.defaultLogConfig,t);r.push(e.serializer(e.getLogMetaConfig(n[e.serviceConfig.logMetaIndexField||"Index"]))),r.push(e.serializer(n))}),Promise.resolve(r.join("\n")+"\n")},e.prototype.getHeaders=function(){return{"Content-Type":"application/json"}},e.prototype.getLogMetaConfig=function(t){return{index:{_index:t||"index",_type:"_doc"}}},e}(i.default);e.default=s},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(0),o=function(){function t(){this.eventEmitter=new n.EventEmitter}return t.prototype.onAdd=function(t){this.eventEmitter.emit("send")},t.prototype.onClear=function(){},t.prototype.sendAll=function(t){},t.prototype.destroy=function(){this.eventEmitter.removeAllListeners(),this.eventEmitter=null},t}();e.default=o},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(0),o=function(){function t(t){this.MAX_BUNDLE_SIZE=100,this.eventEmitter=new n.EventEmitter,t.maxBundle&&(this.MAX_BUNDLE_SIZE=t.maxBundle)}return t.prototype.onAdd=function(t){t&&t.logCount>=this.MAX_BUNDLE_SIZE&&this.eventEmitter.emit("send")},t.prototype.onClear=function(){},t.prototype.sendAll=function(t){this.eventEmitter.emit("send")},t.prototype.destroy=function(){this.eventEmitter.removeAllListeners(),this.eventEmitter=null},t}();e.default=o},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(0),o=r(3),i=function(){function t(t){this.SEND_INTERVAL=15e3,this.eventEmitter=new n.EventEmitter,t.interval&&(this.SEND_INTERVAL=t.interval),this.debouncedSend=o(this.send.bind(this),this.SEND_INTERVAL)}return t.prototype.onAdd=function(t){t&&t.logCount>0&&this.debouncedSend()},t.prototype.onClear=function(){},t.prototype.sendAll=function(t){this.eventEmitter.emit("send")},t.prototype.destroy=function(){this.eventEmitter.removeAllListeners(),this.eventEmitter=null},t.prototype.send=function(){this.eventEmitter.emit("send")},t}();e.default=i},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(0),o=function(){function t(){this.eventEmitter=new n.EventEmitter}return t.prototype.onAdd=function(t){},t.prototype.onClear=function(){},t.prototype.sendAll=function(t){this.eventEmitter.emit("send")},t.prototype.destroy=function(){this.eventEmitter.removeAllListeners(),this.eventEmitter=null},t}();e.default=o}]);
//# sourceMappingURL=advanced-logger.browser.min.js.map