@paybyrd/logger-js
Advanced tools
Comparing version 1.2.1-rc.1 to 1.2.1-rc.2
@@ -1,2 +0,2 @@ | ||
function e(){return e=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},e.apply(this,arguments)}var n;!function(e){e[e.Trace=0]="Trace",e[e.Debug=1]="Debug",e[e.Information=2]="Information",e[e.Warning=3]="Warning",e[e.Error=4]="Error",e[e.Critical=5]="Critical",e[e.None=6]="None"}(n||(n={}));var t=/*#__PURE__*/function(){function t(){}var r=t.prototype;return r.flush=function(){return Promise.resolve()},r.log=function(t){var r,o=e({},t,{error:null==(r=t.error)?void 0:r.toString()});switch(t.level){case n.Trace:return console.trace(o);case n.Debug:return console.debug(o);case n.Warning:return console.warn(o);case n.Error:case n.Critical:return console.error(o);default:return console.log(o)}},t}();function r(e,n,t){if(!e.s){if(t instanceof o){if(!t.s)return void(t.o=r.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(r.bind(null,e,n),r.bind(null,e,2));e.s=n,e.v=t;const i=e.o;i&&i(e)}}var o=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(n,t){var o=new e,i=this.s;if(i){var s=1&i?n:t;if(s){try{r(o,1,s(this.v))}catch(e){r(o,2,e)}return o}return this}return this.o=function(e){try{var i=e.v;1&e.s?r(o,1,n?n(i):i):t?r(o,1,t(i)):r(o,2,i)}catch(e){r(o,2,e)}},o},e}();function i(e){return e instanceof o&&1&e.s}function s(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}var l=/*#__PURE__*/function(){function e(n,r){void 0===r&&(r=new t),this._logger=void 0,this._options=void 0,this._logs=[],this._interval=void 0,this._logger=r,this._options=n,this._interval=setInterval(this.sendBatch.bind(this),1e3*(this._options.batchLogIntervalInSeconds||e.DEFAULT_BATCH_TIMEOUT))}var l=e.prototype;return l.log=function(e){if(this._logger.log(e),this._options.restLoggerUrl)return this._options.minimumLevel&&e.level>=this._options.minimumLevel?this._logger.log({message:"Minimum level not achieved for sending",content:{log:e,minimumLevel:this._options.minimumLevel},method:"log",correlationId:e.correlationId,level:n.Warning}):void this._logs.unshift({executionDate:new Date,log:e});this._logger.log({message:"RestLoggerUrl is not defined",content:e,method:"log",correlationId:e.correlationId,level:n.Warning})},l.flush=function(t){try{var l=this;return void 0===t&&(t=crypto.randomUUID()),clearInterval(l._interval),Promise.resolve(function(e,a){try{var c=s(function(){var e=function(e,n,t){for(var s;;){var l=e();if(i(l)&&(l=l.v),!l)return a;if(l.then){s=0;break}var a=t();if(a&&a.then){if(!i(a)){s=1;break}a=a.s}if(n){var c=n();if(c&&c.then&&!i(c)){s=2;break}}}var u=new o,h=r.bind(null,u,2);return(0===s?l.then(v):1===s?a.then(g):c.then(d)).then(void 0,h),u;function g(o){a=o;do{if(n&&(c=n())&&c.then&&!i(c))return void c.then(d).then(void 0,h);if(!(l=e())||i(l)&&!l.v)return void r(u,1,a);if(l.then)return void l.then(v).then(void 0,h);i(a=t())&&(a=a.v)}while(!a||!a.then);a.then(g).then(void 0,h)}function v(e){e?(a=t())&&a.then?a.then(g).then(void 0,h):g(a):r(u,1,a)}function d(){(l=e())?l.then?l.then(v).then(void 0,h):v(l):r(u,1,a)}}(function(){return!!l._logs.length},void 0,function(){return Promise.resolve(l.sendBatch(t)).then(function(){})});if(e&&e.then)return e.then(function(){})},function(e){l._logger.log({error:e,message:"Error sending messages to API",method:"flush",correlationId:t,level:n.Error})})}catch(e){return a(!0,e)}return c&&c.then?c.then(a.bind(null,!1),a.bind(null,!0)):a(!1,c)}(0,function(n,t){if(l._interval=setInterval(l.sendBatch.bind(l),1e3*(l._options.batchLogIntervalInSeconds||e.DEFAULT_BATCH_TIMEOUT)),n)throw t;return t}))}catch(e){return Promise.reject(e)}},l.sendBatch=function(e){try{var t=this;void 0===e&&(e=crypto.randomUUID()),t._logger.log({message:"Start SendBatch",method:"sendBatch",correlationId:e,level:n.Debug});var r=t._logs.splice(0,10);if(!r.length)return Promise.resolve();var o=s(function(){var o=1e3*(t._options.timeoutInSeconds||30),i=new AbortController,s=setTimeout(function(){return i.abort()},o),l={headers:{"content-type":"application/json"},method:"POST",keepalive:!0,body:JSON.stringify(r.map(function(e){return t.getFullLog(e)})),signal:i.signal},a=new URL(t._options.restLoggerUrl);return t._logger.log({message:"ExternalService - Request ("+a.hostname+")",content:r,method:"sendBatch",correlationId:e,level:n.Debug}),Promise.resolve(fetch(t._options.restLoggerUrl,l)).then(function(o){clearTimeout(s),t._logger.log({message:"ExternalService - Response ("+a.hostname+")",method:"sendBatch",correlationId:e,level:n.Debug}),o.ok||t._logger.log({message:"Error sending messages to API",content:r,method:"sendBatch",correlationId:e,level:n.Error})})},function(o){t._logger.log({error:o,message:"Error sending messages to API",content:r,method:"sendBatch",correlationId:e,level:n.Error})});return Promise.resolve(o&&o.then?o.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},e.getException=function(e){return e?{stackTrace:e.stack,message:e.message,className:e.name}:null},l.getFullLog=function(n){var t=n.log,r="["+this._options.service.name+"] "+t.message;return t.elapsedTimeInMilliseconds&&(r=r+" in "+t.elapsedTimeInMilliseconds+"ms"),{customMessage:t.message,message:r,service:this._options.service,environment:this._options.environment||"Development",executionDate:n.executionDate,entrypoint:"Execute",method:t.method,correlationId:t.correlationId,content:t.content,exeption:e.getException(t.error),level:t.level,elapsedTimeInMilliseconds:t.elapsedTimeInMilliseconds}},e}();l.DEFAULT_BATCH_TIMEOUT=5;export{t as ConsoleLogger,n as LogLevel,l as RestLogger}; | ||
function e(){return e=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},e.apply(this,arguments)}var n;!function(e){e[e.Trace=0]="Trace",e[e.Debug=1]="Debug",e[e.Information=2]="Information",e[e.Warning=3]="Warning",e[e.Error=4]="Error",e[e.Critical=5]="Critical",e[e.None=6]="None"}(n||(n={}));var t=/*#__PURE__*/function(){function t(){}var r=t.prototype;return r.flush=function(){return Promise.resolve()},r.log=function(t){var r,o=e({},t,{error:null==(r=t.error)?void 0:r.toString()});switch(t.level){case n.Trace:return console.trace(o);case n.Debug:return console.debug(o);case n.Warning:return console.warn(o);case n.Error:case n.Critical:return console.error(o);default:return console.log(o)}},t}();function r(e,n,t){if(!e.s){if(t instanceof o){if(!t.s)return void(t.o=r.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(r.bind(null,e,n),r.bind(null,e,2));e.s=n,e.v=t;const i=e.o;i&&i(e)}}var o=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(n,t){var o=new e,i=this.s;if(i){var s=1&i?n:t;if(s){try{r(o,1,s(this.v))}catch(e){r(o,2,e)}return o}return this}return this.o=function(e){try{var i=e.v;1&e.s?r(o,1,n?n(i):i):t?r(o,1,t(i)):r(o,2,i)}catch(e){r(o,2,e)}},o},e}();function i(e){return e instanceof o&&1&e.s}function s(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}var l=/*#__PURE__*/function(){function e(n,r){void 0===r&&(r=new t),this._logger=void 0,this._options=void 0,this._logs=[],this._interval=void 0,this._logger=r,this._options=n,this._interval=setInterval(this.sendBatch.bind(this),1e3*(this._options.batchLogIntervalInSeconds||e.DEFAULT_BATCH_TIMEOUT))}var l=e.prototype;return l.log=function(e){if(this._logger.log(e),this._options.restLoggerUrl)return this._options.minimumLevel&&e.level<this._options.minimumLevel?this._logger.log({message:"Minimum level not achieved for sending",content:{log:e,minimumLevel:this._options.minimumLevel},method:"log",correlationId:e.correlationId,level:n.Warning}):void this._logs.unshift({executionDate:new Date,log:e});this._logger.log({message:"RestLoggerUrl is not defined",content:e,method:"log",correlationId:e.correlationId,level:n.Warning})},l.flush=function(t){try{var l=this;return void 0===t&&(t=crypto.randomUUID()),clearInterval(l._interval),Promise.resolve(function(e,a){try{var c=s(function(){var e=function(e,n,t){for(var s;;){var l=e();if(i(l)&&(l=l.v),!l)return a;if(l.then){s=0;break}var a=t();if(a&&a.then){if(!i(a)){s=1;break}a=a.s}if(n){var c=n();if(c&&c.then&&!i(c)){s=2;break}}}var u=new o,h=r.bind(null,u,2);return(0===s?l.then(v):1===s?a.then(g):c.then(d)).then(void 0,h),u;function g(o){a=o;do{if(n&&(c=n())&&c.then&&!i(c))return void c.then(d).then(void 0,h);if(!(l=e())||i(l)&&!l.v)return void r(u,1,a);if(l.then)return void l.then(v).then(void 0,h);i(a=t())&&(a=a.v)}while(!a||!a.then);a.then(g).then(void 0,h)}function v(e){e?(a=t())&&a.then?a.then(g).then(void 0,h):g(a):r(u,1,a)}function d(){(l=e())?l.then?l.then(v).then(void 0,h):v(l):r(u,1,a)}}(function(){return!!l._logs.length},void 0,function(){return Promise.resolve(l.sendBatch(t)).then(function(){})});if(e&&e.then)return e.then(function(){})},function(e){l._logger.log({error:e,message:"Error sending messages to API",method:"flush",correlationId:t,level:n.Error})})}catch(e){return a(!0,e)}return c&&c.then?c.then(a.bind(null,!1),a.bind(null,!0)):a(!1,c)}(0,function(n,t){if(l._interval=setInterval(l.sendBatch.bind(l),1e3*(l._options.batchLogIntervalInSeconds||e.DEFAULT_BATCH_TIMEOUT)),n)throw t;return t}))}catch(e){return Promise.reject(e)}},l.sendBatch=function(e){try{var t=this;void 0===e&&(e=crypto.randomUUID()),t._logger.log({message:"Start SendBatch",method:"sendBatch",correlationId:e,level:n.Debug});var r=t._logs.splice(0,10);if(!r.length)return Promise.resolve();var o=s(function(){var o=1e3*(t._options.timeoutInSeconds||30),i=new AbortController,s=setTimeout(function(){return i.abort()},o),l={headers:{"content-type":"application/json"},method:"POST",keepalive:!0,body:JSON.stringify(r.map(function(e){return t.getFullLog(e)})),signal:i.signal},a=new URL(t._options.restLoggerUrl);return t._logger.log({message:"ExternalService - Request ("+a.hostname+")",content:r,method:"sendBatch",correlationId:e,level:n.Debug}),Promise.resolve(fetch(t._options.restLoggerUrl,l)).then(function(o){clearTimeout(s),t._logger.log({message:"ExternalService - Response ("+a.hostname+")",method:"sendBatch",correlationId:e,level:n.Debug}),o.ok||t._logger.log({message:"Error sending messages to API",content:r,method:"sendBatch",correlationId:e,level:n.Error})})},function(o){t._logger.log({error:o,message:"Error sending messages to API",content:r,method:"sendBatch",correlationId:e,level:n.Error})});return Promise.resolve(o&&o.then?o.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},e.getException=function(e){return e?{stackTrace:e.stack,message:e.message,className:e.name}:null},l.getFullLog=function(n){var t=n.log,r="["+this._options.service.name+"] "+t.message;return t.elapsedTimeInMilliseconds&&(r=r+" in "+t.elapsedTimeInMilliseconds+"ms"),{customMessage:t.message,message:r,service:this._options.service,environment:this._options.environment||"Development",executionDate:n.executionDate,entrypoint:"Execute",method:t.method,correlationId:t.correlationId,content:t.content,exeption:e.getException(t.error),level:t.level,elapsedTimeInMilliseconds:t.elapsedTimeInMilliseconds}},e}();l.DEFAULT_BATCH_TIMEOUT=5;export{t as ConsoleLogger,n as LogLevel,l as RestLogger}; | ||
//# sourceMappingURL=index.module.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e||self).loggerJs={})}(this,function(e){function n(){return n=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},n.apply(this,arguments)}var t;e.LogLevel=void 0,(t=e.LogLevel||(e.LogLevel={}))[t.Trace=0]="Trace",t[t.Debug=1]="Debug",t[t.Information=2]="Information",t[t.Warning=3]="Warning",t[t.Error=4]="Error",t[t.Critical=5]="Critical",t[t.None=6]="None";var o=/*#__PURE__*/function(){function t(){}var o=t.prototype;return o.flush=function(){return Promise.resolve()},o.log=function(t){var o,r=n({},t,{error:null==(o=t.error)?void 0:o.toString()});switch(t.level){case e.LogLevel.Trace:return console.trace(r);case e.LogLevel.Debug:return console.debug(r);case e.LogLevel.Warning:return console.warn(r);case e.LogLevel.Error:case e.LogLevel.Critical:return console.error(r);default:return console.log(r)}},t}();function r(e,n,t){if(!e.s){if(t instanceof i){if(!t.s)return void(t.o=r.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(r.bind(null,e,n),r.bind(null,e,2));e.s=n,e.v=t;const o=e.o;o&&o(e)}}var i=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(n,t){var o=new e,i=this.s;if(i){var s=1&i?n:t;if(s){try{r(o,1,s(this.v))}catch(e){r(o,2,e)}return o}return this}return this.o=function(e){try{var i=e.v;1&e.s?r(o,1,n?n(i):i):t?r(o,1,t(i)):r(o,2,i)}catch(e){r(o,2,e)}},o},e}();function s(e){return e instanceof i&&1&e.s}function l(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}var a=/*#__PURE__*/function(){function n(e,t){void 0===t&&(t=new o),this._logger=void 0,this._options=void 0,this._logs=[],this._interval=void 0,this._logger=t,this._options=e,this._interval=setInterval(this.sendBatch.bind(this),1e3*(this._options.batchLogIntervalInSeconds||n.DEFAULT_BATCH_TIMEOUT))}var t=n.prototype;return t.log=function(n){if(this._logger.log(n),this._options.restLoggerUrl)return this._options.minimumLevel&&n.level>=this._options.minimumLevel?this._logger.log({message:"Minimum level not achieved for sending",content:{log:n,minimumLevel:this._options.minimumLevel},method:"log",correlationId:n.correlationId,level:e.LogLevel.Warning}):void this._logs.unshift({executionDate:new Date,log:n});this._logger.log({message:"RestLoggerUrl is not defined",content:n,method:"log",correlationId:n.correlationId,level:e.LogLevel.Warning})},t.flush=function(t){try{var o=this;return void 0===t&&(t=crypto.randomUUID()),clearInterval(o._interval),Promise.resolve(function(n,a){try{var c=l(function(){var e=function(e,n,t){for(var o;;){var l=e();if(s(l)&&(l=l.v),!l)return a;if(l.then){o=0;break}var a=t();if(a&&a.then){if(!s(a)){o=1;break}a=a.s}if(n){var c=n();if(c&&c.then&&!s(c)){o=2;break}}}var g=new i,u=r.bind(null,g,2);return(0===o?l.then(h):1===o?a.then(v):c.then(d)).then(void 0,u),g;function v(o){a=o;do{if(n&&(c=n())&&c.then&&!s(c))return void c.then(d).then(void 0,u);if(!(l=e())||s(l)&&!l.v)return void r(g,1,a);if(l.then)return void l.then(h).then(void 0,u);s(a=t())&&(a=a.v)}while(!a||!a.then);a.then(v).then(void 0,u)}function h(e){e?(a=t())&&a.then?a.then(v).then(void 0,u):v(a):r(g,1,a)}function d(){(l=e())?l.then?l.then(h).then(void 0,u):h(l):r(g,1,a)}}(function(){return!!o._logs.length},void 0,function(){return Promise.resolve(o.sendBatch(t)).then(function(){})});if(e&&e.then)return e.then(function(){})},function(n){o._logger.log({error:n,message:"Error sending messages to API",method:"flush",correlationId:t,level:e.LogLevel.Error})})}catch(e){return a(!0,e)}return c&&c.then?c.then(a.bind(null,!1),a.bind(null,!0)):a(!1,c)}(0,function(e,t){if(o._interval=setInterval(o.sendBatch.bind(o),1e3*(o._options.batchLogIntervalInSeconds||n.DEFAULT_BATCH_TIMEOUT)),e)throw t;return t}))}catch(e){return Promise.reject(e)}},t.sendBatch=function(n){try{var t=this;void 0===n&&(n=crypto.randomUUID()),t._logger.log({message:"Start SendBatch",method:"sendBatch",correlationId:n,level:e.LogLevel.Debug});var o=t._logs.splice(0,10);if(!o.length)return Promise.resolve();var r=l(function(){var r=1e3*(t._options.timeoutInSeconds||30),i=new AbortController,s=setTimeout(function(){return i.abort()},r),l={headers:{"content-type":"application/json"},method:"POST",keepalive:!0,body:JSON.stringify(o.map(function(e){return t.getFullLog(e)})),signal:i.signal},a=new URL(t._options.restLoggerUrl);return t._logger.log({message:"ExternalService - Request ("+a.hostname+")",content:o,method:"sendBatch",correlationId:n,level:e.LogLevel.Debug}),Promise.resolve(fetch(t._options.restLoggerUrl,l)).then(function(r){clearTimeout(s),t._logger.log({message:"ExternalService - Response ("+a.hostname+")",method:"sendBatch",correlationId:n,level:e.LogLevel.Debug}),r.ok||t._logger.log({message:"Error sending messages to API",content:o,method:"sendBatch",correlationId:n,level:e.LogLevel.Error})})},function(r){t._logger.log({error:r,message:"Error sending messages to API",content:o,method:"sendBatch",correlationId:n,level:e.LogLevel.Error})});return Promise.resolve(r&&r.then?r.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},n.getException=function(e){return e?{stackTrace:e.stack,message:e.message,className:e.name}:null},t.getFullLog=function(e){var t=e.log,o="["+this._options.service.name+"] "+t.message;return t.elapsedTimeInMilliseconds&&(o=o+" in "+t.elapsedTimeInMilliseconds+"ms"),{customMessage:t.message,message:o,service:this._options.service,environment:this._options.environment||"Development",executionDate:e.executionDate,entrypoint:"Execute",method:t.method,correlationId:t.correlationId,content:t.content,exeption:n.getException(t.error),level:t.level,elapsedTimeInMilliseconds:t.elapsedTimeInMilliseconds}},n}();a.DEFAULT_BATCH_TIMEOUT=5,e.ConsoleLogger=o,e.RestLogger=a}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e||self).loggerJs={})}(this,function(e){function n(){return n=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},n.apply(this,arguments)}var t;e.LogLevel=void 0,(t=e.LogLevel||(e.LogLevel={}))[t.Trace=0]="Trace",t[t.Debug=1]="Debug",t[t.Information=2]="Information",t[t.Warning=3]="Warning",t[t.Error=4]="Error",t[t.Critical=5]="Critical",t[t.None=6]="None";var o=/*#__PURE__*/function(){function t(){}var o=t.prototype;return o.flush=function(){return Promise.resolve()},o.log=function(t){var o,r=n({},t,{error:null==(o=t.error)?void 0:o.toString()});switch(t.level){case e.LogLevel.Trace:return console.trace(r);case e.LogLevel.Debug:return console.debug(r);case e.LogLevel.Warning:return console.warn(r);case e.LogLevel.Error:case e.LogLevel.Critical:return console.error(r);default:return console.log(r)}},t}();function r(e,n,t){if(!e.s){if(t instanceof i){if(!t.s)return void(t.o=r.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(r.bind(null,e,n),r.bind(null,e,2));e.s=n,e.v=t;const o=e.o;o&&o(e)}}var i=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(n,t){var o=new e,i=this.s;if(i){var s=1&i?n:t;if(s){try{r(o,1,s(this.v))}catch(e){r(o,2,e)}return o}return this}return this.o=function(e){try{var i=e.v;1&e.s?r(o,1,n?n(i):i):t?r(o,1,t(i)):r(o,2,i)}catch(e){r(o,2,e)}},o},e}();function s(e){return e instanceof i&&1&e.s}function l(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}var a=/*#__PURE__*/function(){function n(e,t){void 0===t&&(t=new o),this._logger=void 0,this._options=void 0,this._logs=[],this._interval=void 0,this._logger=t,this._options=e,this._interval=setInterval(this.sendBatch.bind(this),1e3*(this._options.batchLogIntervalInSeconds||n.DEFAULT_BATCH_TIMEOUT))}var t=n.prototype;return t.log=function(n){if(this._logger.log(n),this._options.restLoggerUrl)return this._options.minimumLevel&&n.level<this._options.minimumLevel?this._logger.log({message:"Minimum level not achieved for sending",content:{log:n,minimumLevel:this._options.minimumLevel},method:"log",correlationId:n.correlationId,level:e.LogLevel.Warning}):void this._logs.unshift({executionDate:new Date,log:n});this._logger.log({message:"RestLoggerUrl is not defined",content:n,method:"log",correlationId:n.correlationId,level:e.LogLevel.Warning})},t.flush=function(t){try{var o=this;return void 0===t&&(t=crypto.randomUUID()),clearInterval(o._interval),Promise.resolve(function(n,a){try{var c=l(function(){var e=function(e,n,t){for(var o;;){var l=e();if(s(l)&&(l=l.v),!l)return a;if(l.then){o=0;break}var a=t();if(a&&a.then){if(!s(a)){o=1;break}a=a.s}if(n){var c=n();if(c&&c.then&&!s(c)){o=2;break}}}var g=new i,u=r.bind(null,g,2);return(0===o?l.then(h):1===o?a.then(v):c.then(d)).then(void 0,u),g;function v(o){a=o;do{if(n&&(c=n())&&c.then&&!s(c))return void c.then(d).then(void 0,u);if(!(l=e())||s(l)&&!l.v)return void r(g,1,a);if(l.then)return void l.then(h).then(void 0,u);s(a=t())&&(a=a.v)}while(!a||!a.then);a.then(v).then(void 0,u)}function h(e){e?(a=t())&&a.then?a.then(v).then(void 0,u):v(a):r(g,1,a)}function d(){(l=e())?l.then?l.then(h).then(void 0,u):h(l):r(g,1,a)}}(function(){return!!o._logs.length},void 0,function(){return Promise.resolve(o.sendBatch(t)).then(function(){})});if(e&&e.then)return e.then(function(){})},function(n){o._logger.log({error:n,message:"Error sending messages to API",method:"flush",correlationId:t,level:e.LogLevel.Error})})}catch(e){return a(!0,e)}return c&&c.then?c.then(a.bind(null,!1),a.bind(null,!0)):a(!1,c)}(0,function(e,t){if(o._interval=setInterval(o.sendBatch.bind(o),1e3*(o._options.batchLogIntervalInSeconds||n.DEFAULT_BATCH_TIMEOUT)),e)throw t;return t}))}catch(e){return Promise.reject(e)}},t.sendBatch=function(n){try{var t=this;void 0===n&&(n=crypto.randomUUID()),t._logger.log({message:"Start SendBatch",method:"sendBatch",correlationId:n,level:e.LogLevel.Debug});var o=t._logs.splice(0,10);if(!o.length)return Promise.resolve();var r=l(function(){var r=1e3*(t._options.timeoutInSeconds||30),i=new AbortController,s=setTimeout(function(){return i.abort()},r),l={headers:{"content-type":"application/json"},method:"POST",keepalive:!0,body:JSON.stringify(o.map(function(e){return t.getFullLog(e)})),signal:i.signal},a=new URL(t._options.restLoggerUrl);return t._logger.log({message:"ExternalService - Request ("+a.hostname+")",content:o,method:"sendBatch",correlationId:n,level:e.LogLevel.Debug}),Promise.resolve(fetch(t._options.restLoggerUrl,l)).then(function(r){clearTimeout(s),t._logger.log({message:"ExternalService - Response ("+a.hostname+")",method:"sendBatch",correlationId:n,level:e.LogLevel.Debug}),r.ok||t._logger.log({message:"Error sending messages to API",content:o,method:"sendBatch",correlationId:n,level:e.LogLevel.Error})})},function(r){t._logger.log({error:r,message:"Error sending messages to API",content:o,method:"sendBatch",correlationId:n,level:e.LogLevel.Error})});return Promise.resolve(r&&r.then?r.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},n.getException=function(e){return e?{stackTrace:e.stack,message:e.message,className:e.name}:null},t.getFullLog=function(e){var t=e.log,o="["+this._options.service.name+"] "+t.message;return t.elapsedTimeInMilliseconds&&(o=o+" in "+t.elapsedTimeInMilliseconds+"ms"),{customMessage:t.message,message:o,service:this._options.service,environment:this._options.environment||"Development",executionDate:e.executionDate,entrypoint:"Execute",method:t.method,correlationId:t.correlationId,content:t.content,exeption:n.getException(t.error),level:t.level,elapsedTimeInMilliseconds:t.elapsedTimeInMilliseconds}},n}();a.DEFAULT_BATCH_TIMEOUT=5,e.ConsoleLogger=o,e.RestLogger=a}); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "@paybyrd/logger-js", | ||
"version": "1.2.1-rc.1", | ||
"version": "1.2.1-rc.2", | ||
"description": "JS logger implementation", | ||
@@ -5,0 +5,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
63121