chore: reduce logging

Signed-off-by: Ricardo Arturo Cabral Mejía <me@ricardocabral.io>
This commit is contained in:
Ricardo Arturo Cabral Mejía 2023-01-27 22:12:42 -05:00
parent ad7ab69d36
commit 199fa55ea3

View File

@ -4,11 +4,15 @@ import knex, { Knex } from 'knex'
import { createLogger } from '../factories/logger-factory'
((knex) => {
const counters = {}
knex.Client.prototype.releaseConnection = function (connection) {
const released = this.pool.release(connection)
if (released) {
console.log(`${this.config.tag} conneciton pool: ${this.pool.numUsed()} used / ${this.pool.numFree()} free / ${this.pool.numPendingAcquires()} pending`)
counters[this.config.tag] = (counters[this.config.tag] ?? 0) + 1
if (counters[this.config.tag] % 10 === 0) {
console.log(`${this.config.tag} connection pool: ${this.pool.numUsed()} used / ${this.pool.numFree()} free / ${this.pool.numPendingAcquires()} pending`)
}
}
return Promise.resolve()