Skip to content

Commit 4d831a6

Browse files
committed
Hide timeoutify logs behind process.env.DEBUG
1 parent 8e90b4d commit 4d831a6

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/node/Timeoutify.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FindCursor, AbstractCursor } from 'mongodb'
1+
import { AbstractCursor } from 'mongodb'
22

33
export const LOG_PREFIX = '[Timeoutify]'
44

@@ -39,7 +39,10 @@ export class Timeoutify {
3939

4040
if (timeoutMS > 0) {
4141
this.handle = setTimeout(() => {
42-
this.logger.debug(`${this.logPrefix} setTimeout called`)
42+
if (process.env.DEBUG) {
43+
this.logger.debug(`${this.logPrefix} setTimeout called`)
44+
}
45+
4346
if (!this.abortController.signal.aborted) {
4447
this.statusInternal = TimeoutifyStatus.TimedOut
4548
this.abortController.abort()
@@ -99,7 +102,9 @@ export class Timeoutify {
99102
* This ensures the MongoDB Operation is never running for longer than the timeout.
100103
* */
101104
async runMongoOpWithTimeout<T>(cursor: AbstractCursor<T>): Promise<readonly T[]> {
102-
this.logger.debug(`${this.logPrefix} runMongoOpWithTimeout called`)
105+
if (process.env.DEBUG) {
106+
this.logger.debug(`${this.logPrefix} runMongoOpWithTimeout called`)
107+
}
103108
if (this.status === TimeoutifyStatus.Aborted || this.status === TimeoutifyStatus.TimedOut) {
104109
throw new Error(`${this.logPrefix} runMongoOpWithTimeout: AbortSignal already aborted`)
105110
}

0 commit comments

Comments
 (0)