@paybyrd/logger-js
Advanced tools
Comparing version 1.2.0 to 1.2.1-rc.1
@@ -0,1 +1,2 @@ | ||
import { LogLevel } from "./LogLevel"; | ||
export interface IRestLoggerOptions { | ||
@@ -6,2 +7,3 @@ environment: 'Development' | 'Staging' | 'Production'; | ||
timeoutInSeconds: number; | ||
minimumLevel: LogLevel | null | undefined; | ||
service: { | ||
@@ -8,0 +10,0 @@ name: string; |
@@ -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}var s=/*#__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 s=e.prototype;return s.log=function(t){if(this._logger.log(t),this._options.restLoggerUrl){var r="["+this._options.service.name+"] "+t.message;t.elapsedTimeInMilliseconds&&(r=r+" in "+t.elapsedTimeInMilliseconds+"ms"),this._logs.unshift({customMessage:t.message,message:r,service:this._options.service,environment:this._options.environment||"Development",executionDate:new Date,entrypoint:"Execute",method:t.method,correlationId:t.correlationId,content:t.content,exeption:e.getException(t.error),level:t.level,elapsedTimeInMilliseconds:t.elapsedTimeInMilliseconds})}else this._logger.log({message:"RestLoggerUrl is not defined",content:t,method:"log",correlationId:t.correlationId,level:n.Warning})},s.flush=function(){try{var n=function(){t._interval=setInterval(t.sendBatch.bind(t),1e3*(t._options.batchLogIntervalInSeconds||e.DEFAULT_BATCH_TIMEOUT))},t=this;clearInterval(t._interval);var s=function(e,n,t){for(var s;;){var a=e();if(i(a)&&(a=a.v),!a)return c;if(a.then){s=0;break}var c=t();if(c&&c.then){if(!i(c)){s=1;break}c=c.s}if(n){var l=n();if(l&&l.then&&!i(l)){s=2;break}}}var h=new o,u=r.bind(null,h,2);return(0===s?a.then(d):1===s?c.then(v):l.then(g)).then(void 0,u),h;function v(o){c=o;do{if(n&&(l=n())&&l.then&&!i(l))return void l.then(g).then(void 0,u);if(!(a=e())||i(a)&&!a.v)return void r(h,1,c);if(a.then)return void a.then(d).then(void 0,u);i(c=t())&&(c=c.v)}while(!c||!c.then);c.then(v).then(void 0,u)}function d(e){e?(c=t())&&c.then?c.then(v).then(void 0,u):v(c):r(h,1,c)}function g(){(a=e())?a.then?a.then(d).then(void 0,u):d(a):r(h,1,c)}}(function(){return!!t._logs.length},void 0,function(){return Promise.resolve(t.sendBatch()).then(function(){})});return Promise.resolve(s&&s.then?s.then(n):n())}catch(e){return Promise.reject(e)}},s.sendBatch=function(){try{var e=this,t=e._logs.splice(0,10);if(!t.length)return Promise.resolve();var r=crypto.randomUUID(),o=function(o,i){try{var s=(a=1e3*(e._options.timeoutInSeconds||30),c=new AbortController,l=setTimeout(function(){return c.abort()},a),Promise.resolve(fetch(e._options.restLoggerUrl,{headers:{"content-type":"application/json"},method:"POST",keepalive:!0,body:JSON.stringify(t),signal:c.signal})).then(function(o){clearTimeout(l),o.ok||e._logger.log({message:"Error sending messages to API",content:t,method:"sendBatch",correlationId:r,level:n.Error})}))}catch(e){return i(e)}var a,c,l;return s&&s.then?s.then(void 0,i):s}(0,function(o){e._logger.log({error:o,message:"Error sending messages to API",content:t,method:"sendBatch",correlationId:r,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},e}();s.DEFAULT_BATCH_TIMEOUT=5;export{t as ConsoleLogger,n as LogLevel,s 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}var l=/*#__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(t){if(this._logger.log(t),this._options.restLoggerUrl){var o="["+this._options.service.name+"] "+t.message;t.elapsedTimeInMilliseconds&&(o=o+" in "+t.elapsedTimeInMilliseconds+"ms"),this._logs.unshift({customMessage:t.message,message:o,service:this._options.service,environment:this._options.environment||"Development",executionDate:new Date,entrypoint:"Execute",method:t.method,correlationId:t.correlationId,content:t.content,exeption:n.getException(t.error),level:t.level,elapsedTimeInMilliseconds:t.elapsedTimeInMilliseconds})}else this._logger.log({message:"RestLoggerUrl is not defined",content:t,method:"log",correlationId:t.correlationId,level:e.LogLevel.Warning})},t.flush=function(){try{var e=function(){t._interval=setInterval(t.sendBatch.bind(t),1e3*(t._options.batchLogIntervalInSeconds||n.DEFAULT_BATCH_TIMEOUT))},t=this;clearInterval(t._interval);var o=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 v=new i,h=r.bind(null,v,2);return(0===o?l.then(g):1===o?a.then(u):c.then(d)).then(void 0,h),v;function u(o){a=o;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 r(v,1,a);if(l.then)return void l.then(g).then(void 0,h);s(a=t())&&(a=a.v)}while(!a||!a.then);a.then(u).then(void 0,h)}function g(e){e?(a=t())&&a.then?a.then(u).then(void 0,h):u(a):r(v,1,a)}function d(){(l=e())?l.then?l.then(g).then(void 0,h):g(l):r(v,1,a)}}(function(){return!!t._logs.length},void 0,function(){return Promise.resolve(t.sendBatch()).then(function(){})});return Promise.resolve(o&&o.then?o.then(e):e())}catch(e){return Promise.reject(e)}},t.sendBatch=function(){try{var n=this,t=n._logs.splice(0,10);if(!t.length)return Promise.resolve();var o=crypto.randomUUID(),r=function(r,i){try{var s=(l=1e3*(n._options.timeoutInSeconds||30),a=new AbortController,c=setTimeout(function(){return a.abort()},l),Promise.resolve(fetch(n._options.restLoggerUrl,{headers:{"content-type":"application/json"},method:"POST",keepalive:!0,body:JSON.stringify(t),signal:a.signal})).then(function(r){clearTimeout(c),r.ok||n._logger.log({message:"Error sending messages to API",content:t,method:"sendBatch",correlationId:o,level:e.LogLevel.Error})}))}catch(e){return i(e)}var l,a,c;return s&&s.then?s.then(void 0,i):s}(0,function(r){n._logger.log({error:r,message:"Error sending messages to API",content:t,method:"sendBatch",correlationId:o,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},n}();l.DEFAULT_BATCH_TIMEOUT=5,e.ConsoleLogger=o,e.RestLogger=l}); | ||
!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 |
import { IRestLoggerOptions, ILog, ILogger } from "./abstractions"; | ||
interface IException { | ||
className: string; | ||
stackTrace?: string; | ||
message: string; | ||
} | ||
export declare class RestLogger implements ILogger { | ||
@@ -15,6 +10,6 @@ private static readonly DEFAULT_BATCH_TIMEOUT; | ||
log(log: ILog): void; | ||
flush(): Promise<void>; | ||
sendBatch(): Promise<void>; | ||
static getException(error: Error | null | undefined): IException | null; | ||
flush(correlationId?: string): Promise<void>; | ||
sendBatch(correlationId?: string): Promise<void>; | ||
private static getException; | ||
private getFullLog; | ||
} | ||
export {}; |
{ | ||
"name": "@paybyrd/logger-js", | ||
"version": "1.2.0", | ||
"version": "1.2.1-rc.1", | ||
"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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
63127
133
1