Skip to content

Commit

Permalink
As ._log() method is used to log errors, move flag to log slow acquir…
Browse files Browse the repository at this point in the history
…e calls
  • Loading branch information
dgaubert committed May 12, 2020
1 parent f2caadb commit 4038900
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ module.exports = class RedisPool extends EventEmitter {
const client = await pool.acquire();
const elapsedTime = Date.now() - startTime;

if (elapsedTime > this.options.slowPool.elapsedThreshold) {
if (this.options.slowPool.log && elapsedTime > this.options.slowPool.elapsedThreshold) {
this._log({ db: database, action: 'acquire', elapsed: elapsedTime, waiting: pool.pending });
}

Expand Down Expand Up @@ -112,10 +112,6 @@ module.exports = class RedisPool extends EventEmitter {
}

_log(info) {
if (!this.options.slowPool.log) {
return;
}

info = Object.assign({ name: this.options.name }, info)
this.logger.error(JSON.stringify(info));
}
Expand Down

0 comments on commit 4038900

Please sign in to comment.