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

[Diag-Logger] Provide the ability to check if a specific diagnostic log level is enabled before calling and constructing DiagLog messages #1903

Closed
MSNev opened this issue Feb 4, 2021 · 2 comments

Comments

@MSNev
Copy link
Contributor

MSNev commented Feb 4, 2021

Construction of Diagnostic log message strings is expensive

As part of the adding the diag.xxx messages as part of #1877 is was dicussed during the SIG that we should have some way to check whether a specific level is enabled before attempting to log a diagnostic message, especially when creating complex strings.

Splitting this out as a separate issue as this can be added after the API is stable.

Describe the solution you'd like

Provide a helper function or additional function on the DiagLogger to enable checking if called whether the message would be logged or dropped.

Possible options include

  • New method on the interface, could be optional to avoid breaking API and it's only relevant for the LogLevel Diagnostic logger anyway. This would then also be available on the global diag instance.
interface DiagLogger {
  ...
  isLevelEnabled: (level: DiagLogLevel) => bool
  ...

Helper Method check

isDiagLogLevelEnabled(logger: DiagLoger, level: DiagLogLevel): bool;

if (isDiagLogLevelEnabled(myLogger, DiagLogLevel.DEBUG)) {
  myLogger.debug(...);
}

Or a Helper with a callback

diagLogIfEnabled(myLogger, DiagLogLevel.DEBUG, callback: (logger) -> void);

diagLogIfEnabled(myLogger, DiagLogLevel.DEBUG, (logger) => {
  logger.debug(...);
});
Copy link

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the stale label Oct 21, 2024
Copy link

github-actions bot commented Jan 6, 2025

This issue was closed because it has been stale for 14 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant