Logger.only() is dedicated to trigger additional operation, only if needed.
It seems natural to me to be able to gather those information only at some level of logging.
Typically one wants to display errors without triggering potentially costly operations to collect debug information. This could be done later, on the developer's machine.
logger.debug.only(async (level) => {
const debugInfo = await collectDebugInformation();
return `An error occured, diagnostic : ${debugInfo.reason}`
});
The other solution would be to expose the current log level, so it can be checked inside Logger.only().
EDIT: I'm willing to submit a PR for this.