From 667f992ca4bb9f7b50e6f8102ce08f1d3bc0b962 Mon Sep 17 00:00:00 2001 From: titanism <101466223+titanism@users.noreply.github.com> Date: Mon, 16 Oct 2023 04:01:20 -0500 Subject: [PATCH] fix(imapconnection): inherit logger and loggelf from server for IMAPConnection (#533) --- imap-core/lib/imap-connection.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/imap-core/lib/imap-connection.js b/imap-core/lib/imap-connection.js index 53f88ebe..ce478087 100644 --- a/imap-core/lib/imap-connection.js +++ b/imap-core/lib/imap-connection.js @@ -95,16 +95,24 @@ class IMAPConnection extends EventEmitter { this._closingTimeout = null; - this.logger = {}; - ['info', 'debug', 'error'].forEach(level => { - this.logger[level] = (...args) => { - if (!this.ignore) { - this._server.logger[level](...args); - } - }; - }); + if (server.logger) { + this.logger = server.logger; + } else { + this.logger = {}; + ['info', 'debug', 'error'].forEach(level => { + this.logger[level] = (...args) => { + if (!this.ignore) { + this._server.logger[level](...args); + } + }; + }); + } - this.loggelf = () => false; + if (server.loggelf) { + this.loggelf = server.loggelf; + } else { + this.loggelf = () => false; + } } /**