-
-
Notifications
You must be signed in to change notification settings - Fork 295
Enhancement: Replace print() with log() #453
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
Changes from 1 commit
519827b
90bb4f5
36ee4d7
3a3c5c0
55df6f1
f4200e3
fb88b55
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,4 +14,30 @@ class SentryLevel { | |
| /// API name of the level as it is encoded in the JSON protocol. | ||
| final String name; | ||
| final int ordinal; | ||
|
|
||
| /// For use with Dart's | ||
| /// [`log`](https://api.dart.dev/stable/2.12.4/dart-developer/log.html) | ||
| /// function. | ||
| /// These levels are inspired by | ||
| /// https://pub.dev/documentation/logging/latest/logging/Level-class.html | ||
| int toLogLevel() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe we call toDartLogLevel instead? |
||
| switch (this) { | ||
| // Level.SHOUT | ||
| case SentryLevel.fatal: | ||
| return 1200; | ||
| // Level.SEVERE | ||
| case SentryLevel.error: | ||
| return 1000; | ||
| // Level.SEVERE | ||
| case SentryLevel.warning: | ||
| return 900; | ||
| // Level.INFO | ||
| case SentryLevel.info: | ||
| return 8000; | ||
|
ueman marked this conversation as resolved.
Outdated
|
||
| // Level.CONFIG | ||
| case SentryLevel.debug: | ||
| return 700; | ||
| } | ||
| return 1200; | ||
|
ueman marked this conversation as resolved.
Outdated
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import 'dart:async'; | ||
| import 'dart:developer'; | ||
|
|
||
| import 'package:http/http.dart'; | ||
|
|
||
|
|
@@ -254,5 +255,10 @@ void noOpLogger(SentryLevel level, String message) {} | |
|
|
||
| /// A Logger that prints out the level and message | ||
| void dartLogger(SentryLevel level, String message) { | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For v6 I'd like to add an error and stacktrace parameter to our loggers. They can be passed to https://api.flutter.dev/flutter/dart-developer/log.html and look hopefully better |
||
| print('[${level.name}] $message'); | ||
| log( | ||
| '[${level.name}] $message', | ||
| level: level.toLogLevel(), | ||
| name: '[sentry]', | ||
|
ueman marked this conversation as resolved.
Outdated
|
||
| time: getUtcDateTime(), | ||
| ); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.