logger icon indicating copy to clipboard operation
logger copied to clipboard

feat: Expose message, error, and stackTrace in OutputEvent

Open percula opened this issue 3 years ago • 4 comments
trafficstars

This PR lays the groundwork for adding a FirebaseOutput (see below snippet), which I will be uploading as a separate package on pub.dev due to its dependency on Firebase Crashlytics. To be useful, Firebase needs the message, error, and stack trace, so this PR adds those to the OutputEvent. Once this is merged and released in logger, I'll know what version to use as the minimum version for the logger dependency in the FirebaseOutput package.

class FirebaseOutput extends LogOutput {
  List<Level> levels;

  FirebaseOutput({
    this.levels = const [Level.error],
  });

  @override
  void output(OutputEvent event) {
    if (levels.contains(event.level)) {
      FirebaseCrashlytics.instance.recordError(
          event.error,
          event.stackTrace,
          reason: event.message);
    }
  }

}

percula avatar Apr 04 '22 17:04 percula

Where do you get the error, stackTrace and message data from your OutputEvent? My class contains only two fields in version 1.1.0:

class OutputEvent {
  final Level level;
  final List<String> lines;

  OutputEvent(this.level, this.lines);
}

rd-martin-jaeger avatar May 16 '22 10:05 rd-martin-jaeger

Where do you get the error, stackTrace and message data from your OutputEvent? My class contains only two fields in version 1.1.0:

class OutputEvent {
  final Level level;
  final List<String> lines;

  OutputEvent(this.level, this.lines);
}

Yeah, unfortunately they're not included in OutputEvent, I had to add them as part of this PR.

percula avatar May 18 '22 00:05 percula

I strongly vote for this PR: this feature is important. Many log/crashlytics providers like sentry need typed data (ex. StackTrace, error reason, error object, etc.) which are lost when we are using only list of strings in LogOutput. I suggest we add something like origin = LogEvent() field to LogOutput to enable more granural outputs using Firebase/Sentry/other providers which needs access to fields of original event, but not the list of strings as it is now. Or use @percula's approach.

0ttik avatar Jul 08 '22 06:07 0ttik

@leisim Please merge it. it is helpful.

a1573595 avatar Aug 19 '22 02:08 a1573595

Closing as this appears to be implemented via OutputEvent.origin

percula avatar Mar 23 '24 00:03 percula