-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat: Logging docs for Dart and Flutter #4799
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 all commits
ed7e096
7f4f7cc
b1c9aa7
875b255
777c594
b411965
3c81bf2
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 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,69 @@ | ||||||||||||||
| --- | ||||||||||||||
| title: Logging Integration | ||||||||||||||
| caseStyle: canonical | ||||||||||||||
| supportLevel: production | ||||||||||||||
| sidebar_order: 3 | ||||||||||||||
| description: "Learn more about the Sentry Logging integration for the Dart SDK." | ||||||||||||||
| --- | ||||||||||||||
|
|
||||||||||||||
| The `sentry_logging` library provides [Logging](https://pub.dev/packages/logging) support for Sentry using the [onRecord property](https://pub.dev/documentation/logging/latest/logging/Logger/onRecord.html). It is able to collect breadcrumbs and capture events. Once this integration is configured, you can use Logging’s public API exclusively or in combination to the Sentry's SDK API to capture and enrich events. | ||||||||||||||
|
|
||||||||||||||
| The source can be found [on GitHub](https://github.com/getsentry/sentry-dart/tree/main/logging/). | ||||||||||||||
|
|
||||||||||||||
| ## Install | ||||||||||||||
|
|
||||||||||||||
| To add the Logging integration, add the `sentry_logging` dependency. | ||||||||||||||
|
|
||||||||||||||
| ```yml {filename:pubspec.yaml} | ||||||||||||||
| dependencies: | ||||||||||||||
| sentry: ^6.3.0 | ||||||||||||||
| sentry_logging: ^6.3.0 | ||||||||||||||
marandaneto marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
| logging: ^1.0.2 | ||||||||||||||
|
Comment on lines
+19
to
+21
Member
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. is the package on release registry?
Suggested change
Contributor
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. Not yet, that's why it's not using
Contributor
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. |
||||||||||||||
| ``` | ||||||||||||||
|
|
||||||||||||||
| ## Configure | ||||||||||||||
|
|
||||||||||||||
| Configuration should happen as early as possible in your application's lifecycle. | ||||||||||||||
|
|
||||||||||||||
| ```dart | ||||||||||||||
| import 'package:sentry_logging/sentry_logging.dart'; | ||||||||||||||
| import 'package:sentry/sentry.dart'; | ||||||||||||||
|
|
||||||||||||||
| Future<void> main() async { | ||||||||||||||
| await Sentry.init( | ||||||||||||||
| (options) { | ||||||||||||||
| options.dsn = '___PUBLIC_DSN___'; | ||||||||||||||
| options.addIntegration(LoggingIntegration()); | ||||||||||||||
| }, | ||||||||||||||
| appRunner: initApp, // Init your App. | ||||||||||||||
| ); | ||||||||||||||
| } | ||||||||||||||
| ``` | ||||||||||||||
|
|
||||||||||||||
| ## Verify | ||||||||||||||
|
|
||||||||||||||
| This snippet captures an intentional error, so you can test that everything is working as soon as you set it up: | ||||||||||||||
|
|
||||||||||||||
| ```dart | ||||||||||||||
| import 'package:logging/logging.dart'; | ||||||||||||||
|
|
||||||||||||||
| void main() async { | ||||||||||||||
| final log = Logger('MyAwesomeLogger'); | ||||||||||||||
|
|
||||||||||||||
| log.info('a breadcrumb!'); | ||||||||||||||
|
|
||||||||||||||
| try { | ||||||||||||||
| throw Exception(); | ||||||||||||||
| } catch (error, stackTrace) { | ||||||||||||||
| log.severe('an error!', error, stackTrace); | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| ``` | ||||||||||||||
|
|
||||||||||||||
| <Note> | ||||||||||||||
|
|
||||||||||||||
| Learn more about manually capturing an error or message, in our <PlatformLink to="/usage/">Usage documentation</PlatformLink>. | ||||||||||||||
|
|
||||||||||||||
| </Note> | ||||||||||||||
|
|
||||||||||||||
| To view and resolve the recorded message, log into [sentry.io](https://sentry.io) and open your project. Clicking on the error's title will open a page where you can see detailed information and mark it as resolved. | ||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.