fix(support): Print an empty string if no arguments are provided to a logging function (#20424)

This commit is contained in:
Mykola Mokhnach
2024-07-31 08:23:33 +02:00
committed by GitHub
parent 8413ccb4fa
commit 885570e7ca
2 changed files with 7 additions and 5 deletions

View File

@@ -245,9 +245,7 @@ export class Log extends EventEmitter implements Logger {
if (stack) {
messageArguments.unshift(`${stack}\n`);
}
const formattedMessage: string = messageArguments.length
? util.format(...messageArguments)
: '';
const formattedMessage = util.format(...messageArguments);
const m: MessageObject = {
id: this._id++,

View File

@@ -67,8 +67,12 @@ export function getLogger(prefix = null) {
for (const level of LEVELS) {
wrappedLogger[level] = /** @param {any[]} args */ function (...args) {
const finalPrefix = getFinalPrefix(this.prefix, isDebugTimestampLoggingEnabled);
// @ts-ignore This is OK
logger[level](finalPrefix, ...args);
if (args.length) {
// @ts-ignore This is OK
logger[level](finalPrefix, ...args);
} else {
logger[level](finalPrefix, '');
}
};
}
if (!usingGlobalLog) {