Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@paybyrd/logger-js

Package Overview
Dependencies
Maintainers
5
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@paybyrd/logger-js - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2-rc.1

2

dist/index.module.js

@@ -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};
import{v4 as e}from"uuid";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 r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},n.apply(this,arguments)}var t;!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"}(t||(t={}));var r=/*#__PURE__*/function(){function e(){}var r=e.prototype;return r.flush=function(){return Promise.resolve()},r.log=function(e){var r,o=n({},e,{error:null==(r=e.error)?void 0:r.toString()});switch(e.level){case t.Trace:return console.trace(o);case t.Debug:return console.debug(o);case t.Warning:return console.warn(o);case t.Error:case t.Critical:return console.error(o);default:return console.log(o)}},e}();function o(e,n,t){if(!e.s){if(t instanceof i){if(!t.s)return void(t.o=o.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(o.bind(null,e,n),o.bind(null,e,2));e.s=n,e.v=t;const r=e.o;r&&r(e)}}var i=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(n,t){var r=new e,i=this.s;if(i){var s=1&i?n:t;if(s){try{o(r,1,s(this.v))}catch(e){o(r,2,e)}return r}return this}return this.o=function(e){try{var i=e.v;1&e.s?o(r,1,n?n(i):i):t?o(r,1,t(i)):o(r,2,i)}catch(e){o(r,2,e)}},r},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 r),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 a=n.prototype;return a.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:t.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:t.Warning})},a.flush=function(r){try{var a=this;return void 0===r&&(r=e()),clearInterval(a._interval),Promise.resolve(function(e,n){try{var c=l(function(){var e=function(e,n,t){for(var r;;){var l=e();if(s(l)&&(l=l.v),!l)return a;if(l.then){r=0;break}var a=t();if(a&&a.then){if(!s(a)){r=1;break}a=a.s}if(n){var c=n();if(c&&c.then&&!s(c)){r=2;break}}}var u=new i,h=o.bind(null,u,2);return(0===r?l.then(v):1===r?a.then(g):c.then(d)).then(void 0,h),u;function g(r){a=r;do{if(n&&(c=n())&&c.then&&!s(c))return void c.then(d).then(void 0,h);if(!(l=e())||s(l)&&!l.v)return void o(u,1,a);if(l.then)return void l.then(v).then(void 0,h);s(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):o(u,1,a)}function d(){(l=e())?l.then?l.then(v).then(void 0,h):v(l):o(u,1,a)}}(function(){return!!a._logs.length},void 0,function(){return Promise.resolve(a.sendBatch(r)).then(function(){})});if(e&&e.then)return e.then(function(){})},function(e){a._logger.log({error:e,message:"Error sending messages to API",method:"flush",correlationId:r,level:t.Error})})}catch(e){return n(!0,e)}return c&&c.then?c.then(n.bind(null,!1),n.bind(null,!0)):n(!1,c)}(0,function(e,t){if(a._interval=setInterval(a.sendBatch.bind(a),1e3*(a._options.batchLogIntervalInSeconds||n.DEFAULT_BATCH_TIMEOUT)),e)throw t;return t}))}catch(e){return Promise.reject(e)}},a.sendBatch=function(n){try{var r=this;void 0===n&&(n=e()),r._logger.log({message:"Start SendBatch",method:"sendBatch",correlationId:n,level:t.Debug});var o=r._logs.splice(0,10);if(!o.length)return Promise.resolve();var i=l(function(){var e=1e3*(r._options.timeoutInSeconds||30),i=new AbortController,s=setTimeout(function(){return i.abort()},e),l={headers:{"content-type":"application/json"},method:"POST",keepalive:!0,body:JSON.stringify(o.map(function(e){return r.getFullLog(e)})),signal:i.signal},a=new URL(r._options.restLoggerUrl);return r._logger.log({message:"ExternalService - Request ("+a.hostname+")",content:o,method:"sendBatch",correlationId:n,level:t.Debug}),Promise.resolve(fetch(r._options.restLoggerUrl,l)).then(function(e){clearTimeout(s),r._logger.log({message:"ExternalService - Response ("+a.hostname+")",method:"sendBatch",correlationId:n,level:t.Debug}),e.ok||r._logger.log({message:"Error sending messages to API",content:o,method:"sendBatch",correlationId:n,level:t.Error})})},function(e){r._logger.log({error:e,message:"Error sending messages to API",content:o,method:"sendBatch",correlationId:n,level:t.Error})});return Promise.resolve(i&&i.then?i.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},a.getFullLog=function(e){var t=e.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: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;export{r as ConsoleLogger,t as LogLevel,a 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,require("uuid")):"function"==typeof define&&define.amd?define(["exports","uuid"],n):n((e||self).loggerJs={},e.uuid)}(this,function(e,n){function t(){return t=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},t.apply(this,arguments)}var o;e.LogLevel=void 0,(o=e.LogLevel||(e.LogLevel={}))[o.Trace=0]="Trace",o[o.Debug=1]="Debug",o[o.Information=2]="Information",o[o.Warning=3]="Warning",o[o.Error=4]="Error",o[o.Critical=5]="Critical",o[o.None=6]="None";var r=/*#__PURE__*/function(){function n(){}var o=n.prototype;return o.flush=function(){return Promise.resolve()},o.log=function(n){var o,r=t({},n,{error:null==(o=n.error)?void 0:o.toString()});switch(n.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)}},n}();function i(e,n,t){if(!e.s){if(t instanceof s){if(!t.s)return void(t.o=i.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(i.bind(null,e,n),i.bind(null,e,2));e.s=n,e.v=t;const o=e.o;o&&o(e)}}var s=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(n,t){var o=new e,r=this.s;if(r){var s=1&r?n:t;if(s){try{i(o,1,s(this.v))}catch(e){i(o,2,e)}return o}return this}return this.o=function(e){try{var r=e.v;1&e.s?i(o,1,n?n(r):r):t?i(o,1,t(r)):i(o,2,r)}catch(e){i(o,2,e)}},o},e}();function l(e){return e instanceof s&&1&e.s}function a(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}var c=/*#__PURE__*/function(){function t(e,n){void 0===n&&(n=new r),this._logger=void 0,this._options=void 0,this._logs=[],this._interval=void 0,this._logger=n,this._options=e,this._interval=setInterval(this.sendBatch.bind(this),1e3*(this._options.batchLogIntervalInSeconds||t.DEFAULT_BATCH_TIMEOUT))}var o=t.prototype;return o.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})},o.flush=function(o){try{var r=this;return void 0===o&&(o=n.v4()),clearInterval(r._interval),Promise.resolve(function(n,t){try{var c=a(function(){var e=function(e,n,t){for(var o;;){var r=e();if(l(r)&&(r=r.v),!r)return a;if(r.then){o=0;break}var a=t();if(a&&a.then){if(!l(a)){o=1;break}a=a.s}if(n){var c=n();if(c&&c.then&&!l(c)){o=2;break}}}var u=new s,g=i.bind(null,u,2);return(0===o?r.then(h):1===o?a.then(v):c.then(d)).then(void 0,g),u;function v(o){a=o;do{if(n&&(c=n())&&c.then&&!l(c))return void c.then(d).then(void 0,g);if(!(r=e())||l(r)&&!r.v)return void i(u,1,a);if(r.then)return void r.then(h).then(void 0,g);l(a=t())&&(a=a.v)}while(!a||!a.then);a.then(v).then(void 0,g)}function h(e){e?(a=t())&&a.then?a.then(v).then(void 0,g):v(a):i(u,1,a)}function d(){(r=e())?r.then?r.then(h).then(void 0,g):h(r):i(u,1,a)}}(function(){return!!r._logs.length},void 0,function(){return Promise.resolve(r.sendBatch(o)).then(function(){})});if(e&&e.then)return e.then(function(){})},function(n){r._logger.log({error:n,message:"Error sending messages to API",method:"flush",correlationId:o,level:e.LogLevel.Error})})}catch(e){return t(!0,e)}return c&&c.then?c.then(t.bind(null,!1),t.bind(null,!0)):t(!1,c)}(0,function(e,n){if(r._interval=setInterval(r.sendBatch.bind(r),1e3*(r._options.batchLogIntervalInSeconds||t.DEFAULT_BATCH_TIMEOUT)),e)throw n;return n}))}catch(e){return Promise.reject(e)}},o.sendBatch=function(t){try{var o=this;void 0===t&&(t=n.v4()),o._logger.log({message:"Start SendBatch",method:"sendBatch",correlationId:t,level:e.LogLevel.Debug});var r=o._logs.splice(0,10);if(!r.length)return Promise.resolve();var i=a(function(){var n=1e3*(o._options.timeoutInSeconds||30),i=new AbortController,s=setTimeout(function(){return i.abort()},n),l={headers:{"content-type":"application/json"},method:"POST",keepalive:!0,body:JSON.stringify(r.map(function(e){return o.getFullLog(e)})),signal:i.signal},a=new URL(o._options.restLoggerUrl);return o._logger.log({message:"ExternalService - Request ("+a.hostname+")",content:r,method:"sendBatch",correlationId:t,level:e.LogLevel.Debug}),Promise.resolve(fetch(o._options.restLoggerUrl,l)).then(function(n){clearTimeout(s),o._logger.log({message:"ExternalService - Response ("+a.hostname+")",method:"sendBatch",correlationId:t,level:e.LogLevel.Debug}),n.ok||o._logger.log({message:"Error sending messages to API",content:r,method:"sendBatch",correlationId:t,level:e.LogLevel.Error})})},function(n){o._logger.log({error:n,message:"Error sending messages to API",content:r,method:"sendBatch",correlationId:t,level:e.LogLevel.Error})});return Promise.resolve(i&&i.then?i.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},t.getException=function(e){return e?{stackTrace:e.stack,message:e.message,className:e.name}:null},o.getFullLog=function(e){var n=e.log,o="["+this._options.service.name+"] "+n.message;return n.elapsedTimeInMilliseconds&&(o=o+" in "+n.elapsedTimeInMilliseconds+"ms"),{customMessage:n.message,message:o,service:this._options.service,environment:this._options.environment||"Development",executionDate:e.executionDate,entrypoint:"Execute",method:n.method,correlationId:n.correlationId,content:n.content,exeption:t.getException(n.error),level:n.level,elapsedTimeInMilliseconds:n.elapsedTimeInMilliseconds}},t}();c.DEFAULT_BATCH_TIMEOUT=5,e.ConsoleLogger=r,e.RestLogger=c});
//# sourceMappingURL=index.umd.js.map
{
"name": "@paybyrd/logger-js",
"version": "1.2.1",
"version": "1.2.2-rc.1",
"description": "JS logger implementation",

@@ -44,2 +44,3 @@ "repository": {

"devDependencies": {
"@types/uuid": "^9.0.8",
"live-server": "^1.2.2",

@@ -50,4 +51,5 @@ "microbundle": "^0.15.1",

"dependencies": {
"buffer": "^6.0.3"
"buffer": "^6.0.3",
"uuid": "^9.0.1"
}
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc