Skip to content

Allow to perform operation depending on the log level #2

@JesusTheHun

Description

@JesusTheHun

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions