Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to perform operation depending on the log level #2

Open
JesusTheHun opened this issue Nov 28, 2023 · 0 comments
Open

Allow to perform operation depending on the log level #2

JesusTheHun opened this issue Nov 28, 2023 · 0 comments

Comments

@JesusTheHun
Copy link

JesusTheHun commented Nov 28, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant