Skip to content

Commit

Permalink
ref #29, added bind to function
Browse files Browse the repository at this point in the history
  • Loading branch information
umang committed Feb 22, 2022
1 parent 4c43302 commit e59eeed
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
9 changes: 6 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ var jsLogger = /*#__PURE__*/function () {

if (this.interval) return;
this.interval = setInterval(function () {
return _this.ajaxCall();
//FIXME: replace with one function for bind and also calling
_this.ajaxCall.bind(_this);

_this.ajaxCall();
}, this.timeInterval);
}
}, {
Expand Down Expand Up @@ -244,8 +247,8 @@ var jsLogger = /*#__PURE__*/function () {
}

if (!pending_logs || pending_logs === 0) {
this.isAjaxCompleted = true;
this.endCheck();
this.isAjaxCompleted = true; //this.endCheck();

return;
}

Expand Down
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "jslogger",
"version": "0.0.1",
"name": "@nudjur/js-logger",
"version": "0.0.4",
"description": "To add structured logs in your node project",
"main": "dist/index.js",
"directories": {
"example": "example"
},
"registry-url": "https://registry.npmjs.org/",
"scripts": {
"build": "npx babel src --out-dir dist",
"test": "echo \"Error: no test specified\" && exit 1"
Expand All @@ -28,5 +29,8 @@
"@babel/cli": "^7.15.7",
"@babel/core": "^7.15.8",
"@babel/preset-env": "^7.15.8"
}
},
"keywords": [
"js-logger"
]
}
8 changes: 6 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ class jsLogger {

startCheck() {
if (this.interval) return;
this.interval = setInterval(() => this.ajaxCall(), this.timeInterval);
this.interval = setInterval(() => {
//FIXME: replace with one function for bind and also calling
this.ajaxCall.bind(this);
this.ajaxCall();
}, this.timeInterval);
}
endCheck() {
if (!this.interval) return;
Expand Down Expand Up @@ -211,7 +215,7 @@ class jsLogger {

if (!pending_logs || pending_logs === 0) {
this.isAjaxCompleted = true;
this.endCheck();
//this.endCheck();
return;
}

Expand Down

0 comments on commit e59eeed

Please sign in to comment.