Skip to content

Add onBefore callback #484

Open
Open
@invipal

Description

@invipal

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;
   }
};

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions