Skip to content

Commit

Permalink
chore(log): Show log level in debug logs (#2717)
Browse files Browse the repository at this point in the history
When emitting an INFO/WARN/ERROR log via the `debug` interface, the
message will now include the severity level, so it's easier to spot
errors. DEBUG is not shown so it's not annoying.
  • Loading branch information
spalladino authored Oct 6, 2023
1 parent 33a230a commit 2b87381
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions yarn-project/foundation/src/log/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,12 @@ function logWithDebug(debug: debug.Debugger, level: LogLevel, msg: string, data?
handler(level, debug.namespace, msg, data);
}

const msgWithData = data ? `${msg} ${fmtLogData(data)}` : msg;
msg = data ? `${msg} ${fmtLogData(data)}` : msg;
if (debug.enabled) {
debug(msgWithData);
if (level !== 'debug') msg = `${level.toUpperCase()} ${msg}`;
debug(msg);
} else if (LogLevels.indexOf(level) <= LogLevels.indexOf(currentLevel)) {
printLog(`${getPrefix(debug, level)} ${msgWithData}`);
printLog(`${getPrefix(debug, level)} ${msg}`);
}
}

Expand Down

0 comments on commit 2b87381

Please sign in to comment.