Skip to content

feat: Expose message, error, and stackTrace in OutputEvent#133

Closed
percula wants to merge 1 commit into
simc:masterfrom
percula:master
Closed

feat: Expose message, error, and stackTrace in OutputEvent#133
percula wants to merge 1 commit into
simc:masterfrom
percula:master

Conversation

@percula

@percula percula commented Apr 4, 2022

Copy link
Copy Markdown

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

}

@rd-martin-jaeger

Copy link
Copy Markdown

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

@percula

percula commented May 18, 2022

Copy link
Copy Markdown
Author

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.

@0ttik

0ttik commented Jul 8, 2022

Copy link
Copy Markdown

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.

@a1573595

Copy link
Copy Markdown

@leisim Please merge it. it is helpful.

@percula

percula commented Mar 23, 2024

Copy link
Copy Markdown
Author

Closing as this appears to be implemented via OutputEvent.origin

@percula percula closed this Mar 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants