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

Add onBefore callback #484

Open
invipal opened this issue May 6, 2024 · 0 comments
Open

Add onBefore callback #484

invipal opened this issue May 6, 2024 · 0 comments

Comments

@invipal
Copy link

invipal commented May 6, 2024

Hello,

Sometimes there can be different needs depending on the type of log or its source, or we might need to ignore them. For such situations, it would be very beneficial to be able to modify the log request before it's processed through a callback like onBefore, or to be able to completely ignore the log request.

For example;

Logger.root.onRecord = (event) {
    if (event.loggerName == 'xxx') {
      return event.copyWith(message: newFormat(event.message)); // format event message
    } else if (event.level == Level.WARNING) {
      return null; // ignore this record/event
    } else {
      return event;
   }
};
@mosuem mosuem transferred this issue from dart-archive/logging Oct 17, 2024
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

2 participants