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.0.0 to 1.1.0-rc.1

5

dist/abstractions/ILog.d.ts

@@ -7,4 +7,5 @@ import { LogLevel } from "./LogLevel";

message: string;
content?: object;
error?: object;
content?: object | null | undefined;
error?: Error | null | undefined;
elapsedTimeInMilliseconds?: number | null | undefined;
}

2

dist/index.module.js

@@ -1,2 +0,2 @@

function n(){return n=Object.assign?Object.assign.bind():function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},n.apply(this,arguments)}var t,e=/*#__PURE__*/function(){function t(){}var e=t.prototype;return e.flush=function(){return Promise.resolve()},e.log=function(t){var e,r=n({},t,{error:null==(e=t.error)?void 0:e.toString()});console.log(r)},t}();function r(n,t,e){if(!n.s){if(e instanceof o){if(!e.s)return void(e.o=r.bind(null,n,t));1&t&&(t=e.s),e=e.v}if(e&&e.then)return void e.then(r.bind(null,n,t),r.bind(null,n,2));n.s=t,n.v=e;const i=n.o;i&&i(n)}}!function(n){n[n.Trace=0]="Trace",n[n.Debug=1]="Debug",n[n.Information=2]="Information",n[n.Warning=3]="Warning",n[n.Error=4]="Error",n[n.Critical=5]="Critical",n[n.None=6]="None"}(t||(t={}));var o=/*#__PURE__*/function(){function n(){}return n.prototype.then=function(t,e){var o=new n,i=this.s;if(i){var s=1&i?t:e;if(s){try{r(o,1,s(this.v))}catch(n){r(o,2,n)}return o}return this}return this.o=function(n){try{var i=n.v;1&n.s?r(o,1,t?t(i):i):e?r(o,1,e(i)):r(o,2,i)}catch(n){r(o,2,n)}},o},n}();function i(n){return n instanceof o&&1&n.s}var s=/*#__PURE__*/function(){function s(n,t){void 0===t&&(t=new e),this._logger=void 0,this._options=void 0,this._logs=[],this._interval=void 0,this._logger=t,this._options=n,this._interval=setInterval(this.sendBatch.bind(this),1e3*(this._options.batchLogIntervalInSeconds||s.DEFAULT_BATCH_TIMEOUT))}var a=s.prototype;return a.log=function(t){var e;this._logger.log(t),this._options.restLoggerUrl&&this._logs.unshift({customMessage:t.message,message:"["+this._options.service.name+"] "+t.message,service:this._options.service,environment:this._options.environment||"Development",executionDate:new Date,entrypoint:"Execute",method:t.method,correlationId:t.correlationId,content:n({},t.content,{error:null==(e=t.error)?void 0:e.toString()}),level:t.level})},a.flush=function(){try{var n=function(){t._interval=setInterval(t.sendBatch.bind(t),1e3*(t._options.batchLogIntervalInSeconds||s.DEFAULT_BATCH_TIMEOUT))},t=this;clearInterval(t._interval);var e=function(n,t,e){for(var s;;){var a=n();if(i(a)&&(a=a.v),!a)return c;if(a.then){s=0;break}var c=e();if(c&&c.then){if(!i(c)){s=1;break}c=c.s}if(t){var h=t();if(h&&h.then&&!i(h)){s=2;break}}}var l=new o,v=r.bind(null,l,2);return(0===s?a.then(f):1===s?c.then(u):h.then(d)).then(void 0,v),l;function u(o){c=o;do{if(t&&(h=t())&&h.then&&!i(h))return void h.then(d).then(void 0,v);if(!(a=n())||i(a)&&!a.v)return void r(l,1,c);if(a.then)return void a.then(f).then(void 0,v);i(c=e())&&(c=c.v)}while(!c||!c.then);c.then(u).then(void 0,v)}function f(n){n?(c=e())&&c.then?c.then(u).then(void 0,v):u(c):r(l,1,c)}function d(){(a=n())?a.then?a.then(f).then(void 0,v):f(a):r(l,1,c)}}(function(){return!!t._logs.length},void 0,function(){return Promise.resolve(t.sendBatch()).then(function(){})});return Promise.resolve(e&&e.then?e.then(n):n())}catch(n){return Promise.reject(n)}},a.sendBatch=function(){try{var n=this,e=n._logs.splice(0,10);if(!e.length)return Promise.resolve();var r=crypto.randomUUID(),o=function(o,i){try{var s=(a=1e3*(n._options.timeoutInSeconds||30),c=new AbortController,h=setTimeout(function(){return c.abort()},a),Promise.resolve(fetch(n._options.restLoggerUrl,{headers:{"content-type":"application/json"},method:"POST",keepalive:!0,body:JSON.stringify(e),signal:c.signal})).then(function(o){clearTimeout(h),o.ok||n._logger.log({message:"Error sending messages to API",content:e,method:"sendBatch",correlationId:r,level:t.Error})}))}catch(n){return i(n)}var a,c,h;return s&&s.then?s.then(void 0,i):s}(0,function(o){n._logger.log({error:o,message:"Error sending messages to API",content:e,method:"sendBatch",correlationId:r,level:t.Error})});return Promise.resolve(o&&o.then?o.then(function(){}):void 0)}catch(n){return Promise.reject(n)}},s}();s.DEFAULT_BATCH_TIMEOUT=5;export{e as ConsoleLogger,t 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,t=/*#__PURE__*/function(){function n(){}var t=n.prototype;return t.flush=function(){return Promise.resolve()},t.log=function(n){var t,r=e({},n,{error:null==(t=n.error)?void 0:t.toString()});console.log(r)},n}();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)}}!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 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(n){if(this._logger.log(n),this._options.restLoggerUrl){var t="["+this._options.service.name+"] "+n.message;n.elapsedTimeInMilliseconds&&(t=t+" in "+n.elapsedTimeInMilliseconds+"ms"),this._logs.unshift({customMessage:n.message,message:t,service:this._options.service,environment:this._options.environment||"Development",executionDate:new Date,entrypoint:"Execute",method:n.method,correlationId:n.correlationId,content:n.content,exeption:e.getException(n.error),level:n.level,elapsedTimeInMilliseconds:n.elapsedTimeInMilliseconds})}},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(f):1===s?c.then(v):l.then(d)).then(void 0,u),h;function v(o){c=o;do{if(n&&(l=n())&&l.then&&!i(l))return void l.then(d).then(void 0,u);if(!(a=e())||i(a)&&!a.v)return void r(h,1,c);if(a.then)return void a.then(f).then(void 0,u);i(c=t())&&(c=c.v)}while(!c||!c.then);c.then(v).then(void 0,u)}function f(e){e?(c=t())&&c.then?c.then(v).then(void 0,u):v(c):r(h,1,c)}function d(){(a=e())?a.then?a.then(f).then(void 0,u):f(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};
//# 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,o=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.flush=function(){return Promise.resolve()},t.log=function(e){var t,o=n({},e,{error:null==(t=e.error)?void 0:t.toString()});console.log(o)},e}();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)}}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 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 a=/*#__PURE__*/function(){function t(e,n){void 0===n&&(n=new o),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 a=t.prototype;return a.log=function(e){var t;this._logger.log(e),this._options.restLoggerUrl&&this._logs.unshift({customMessage:e.message,message:"["+this._options.service.name+"] "+e.message,service:this._options.service,environment:this._options.environment||"Development",executionDate:new Date,entrypoint:"Execute",method:e.method,correlationId:e.correlationId,content:n({},e.content,{error:null==(t=e.error)?void 0:t.toString()}),level:e.level})},a.flush=function(){try{var e=function(){n._interval=setInterval(n.sendBatch.bind(n),1e3*(n._options.batchLogIntervalInSeconds||t.DEFAULT_BATCH_TIMEOUT))},n=this;clearInterval(n._interval);var o=function(e,n,t){for(var o;;){var a=e();if(s(a)&&(a=a.v),!a)return l;if(a.then){o=0;break}var l=t();if(l&&l.then){if(!s(l)){o=1;break}l=l.s}if(n){var c=n();if(c&&c.then&&!s(c)){o=2;break}}}var h=new i,v=r.bind(null,h,2);return(0===o?a.then(f):1===o?l.then(u):c.then(g)).then(void 0,v),h;function u(o){l=o;do{if(n&&(c=n())&&c.then&&!s(c))return void c.then(g).then(void 0,v);if(!(a=e())||s(a)&&!a.v)return void r(h,1,l);if(a.then)return void a.then(f).then(void 0,v);s(l=t())&&(l=l.v)}while(!l||!l.then);l.then(u).then(void 0,v)}function f(e){e?(l=t())&&l.then?l.then(u).then(void 0,v):u(l):r(h,1,l)}function g(){(a=e())?a.then?a.then(f).then(void 0,v):f(a):r(h,1,l)}}(function(){return!!n._logs.length},void 0,function(){return Promise.resolve(n.sendBatch()).then(function(){})});return Promise.resolve(o&&o.then?o.then(e):e())}catch(e){return Promise.reject(e)}},a.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=(a=1e3*(n._options.timeoutInSeconds||30),l=new AbortController,c=setTimeout(function(){return l.abort()},a),Promise.resolve(fetch(n._options.restLoggerUrl,{headers:{"content-type":"application/json"},method:"POST",keepalive:!0,body:JSON.stringify(t),signal:l.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 a,l,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)}},t}();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,o=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.flush=function(){return Promise.resolve()},t.log=function(e){var t,o=n({},e,{error:null==(t=e.error)?void 0:t.toString()});console.log(o)},e}();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)}}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 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 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(e){if(this._logger.log(e),this._options.restLoggerUrl){var t="["+this._options.service.name+"] "+e.message;e.elapsedTimeInMilliseconds&&(t=t+" in "+e.elapsedTimeInMilliseconds+"ms"),this._logs.unshift({customMessage:e.message,message:t,service:this._options.service,environment:this._options.environment||"Development",executionDate:new Date,entrypoint:"Execute",method:e.method,correlationId:e.correlationId,content:e.content,exeption:n.getException(e.error),level:e.level,elapsedTimeInMilliseconds:e.elapsedTimeInMilliseconds})}},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 a=e();if(s(a)&&(a=a.v),!a)return l;if(a.then){o=0;break}var l=t();if(l&&l.then){if(!s(l)){o=1;break}l=l.s}if(n){var c=n();if(c&&c.then&&!s(c)){o=2;break}}}var h=new i,u=r.bind(null,h,2);return(0===o?a.then(f):1===o?l.then(v):c.then(d)).then(void 0,u),h;function v(o){l=o;do{if(n&&(c=n())&&c.then&&!s(c))return void c.then(d).then(void 0,u);if(!(a=e())||s(a)&&!a.v)return void r(h,1,l);if(a.then)return void a.then(f).then(void 0,u);s(l=t())&&(l=l.v)}while(!l||!l.then);l.then(v).then(void 0,u)}function f(e){e?(l=t())&&l.then?l.then(v).then(void 0,u):v(l):r(h,1,l)}function d(){(a=e())?a.then?a.then(f).then(void 0,u):f(a):r(h,1,l)}}(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=(a=1e3*(n._options.timeoutInSeconds||30),l=new AbortController,c=setTimeout(function(){return l.abort()},a),Promise.resolve(fetch(n._options.restLoggerUrl,{headers:{"content-type":"application/json"},method:"POST",keepalive:!0,body:JSON.stringify(t),signal:l.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 a,l,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}();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 {

@@ -12,2 +17,4 @@ private static readonly DEFAULT_BATCH_TIMEOUT;

sendBatch(): Promise<void>;
static getException(error: Error | null | undefined): IException | null;
}
export {};
{
"name": "@paybyrd/logger-js",
"version": "1.0.0",
"version": "1.1.0-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

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