Skip to content

Commit 5a0a595

Browse files
authored
feat: Logging docs for Dart and Flutter (#4799)
1 parent f6f5bb9 commit 5a0a595

File tree

4 files changed

+77
-1
lines changed

4 files changed

+77
-1
lines changed

src/includes/getting-started-primer/dart.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ Sentry's Dart SDK enables automatic reporting of errors, messages, and exception
1313
- [User Feedback](/platforms/dart/enriching-events/user-feedback/) provides the ability to collect user information when an event occurs.
1414
- [Performance Monitoring](/product/performance/) creates transactions for:
1515
- [HTTP requests](/platforms/dart/configuration/integrations/http-integration/#performance-monitoring-for-http-requests)
16+
- [Logging Integration](/platforms/dart/configuration/integrations/logging)

src/includes/getting-started-primer/flutter.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,11 @@ Features:
1616
- via the Native SDKs [Automatic Breadcrumbs for Android](/platforms/android/enriching-events/breadcrumbs/#automatic-breadcrumbs) and [Automatic Breadcrumbs for iOS](/platforms/apple/configuration/integrations/default/#sentryautobreadcrumbtrackingintegration)
1717
- as well as `http` with the [Dart SDK](/platforms/dart/)
1818
- [Release Health](/product/releases/health/) tracks crash free users and sessions
19+
- [Attachments](/platforms/flutter/enriching-events/attachments/) enrich your event by storing additional files, such as config or log files.
20+
- [User Feedback](/platforms/flutter/enriching-events/user-feedback/) provides the ability to collect user information when an event occurs.
21+
- [Performance Monitoring](/product/performance/) creates transactions for:
22+
- [HTTP requests](/platforms/flutter/performance/instrumentation/automatic-instrumentation/#httpclient-library-instrumentation)
23+
- [Routing Instumentation](/platforms/flutter/performance/instrumentation/automatic-instrumentation/#routing-instumentation)
24+
- [Logging Integration](/platforms/dart/configuration/integrations/logging)
1925
- Limited support for Flutter Web, Windows, and Linux
2026
- Under the hood the SDK relies on the [Dart SDK](/platforms/dart/); the minimum required version is `2.12.0` and Flutter SDK version is `1.17.0`.

src/platforms/android/configuration/integrations/timber.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ SentryAndroid.init(this, options -> {
8282

8383
## Verify
8484

85-
This snippet includes a HTTP Request and captures an intentional message, so you can test that everything is working as soon as you set it up:
85+
This snippet captures an intentional error, so you can test that everything is working as soon as you set it up:
8686

8787
```kotlin
8888
import androidx.appcompat.app.AppCompatActivity
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
title: Logging Integration
3+
caseStyle: canonical
4+
supportLevel: production
5+
sidebar_order: 3
6+
description: "Learn more about the Sentry Logging integration for the Dart SDK."
7+
---
8+
9+
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.
10+
11+
The source can be found [on GitHub](https://github.com/getsentry/sentry-dart/tree/main/logging/).
12+
13+
## Install
14+
15+
To add the Logging integration, add the `sentry_logging` dependency.
16+
17+
```yml {filename:pubspec.yaml}
18+
dependencies:
19+
sentry: ^6.3.0
20+
sentry_logging: ^6.3.0
21+
logging: ^1.0.2
22+
```
23+
24+
## Configure
25+
26+
Configuration should happen as early as possible in your application's lifecycle.
27+
28+
```dart
29+
import 'package:sentry_logging/sentry_logging.dart';
30+
import 'package:sentry/sentry.dart';
31+
32+
Future<void> main() async {
33+
await Sentry.init(
34+
(options) {
35+
options.dsn = '___PUBLIC_DSN___';
36+
options.addIntegration(LoggingIntegration());
37+
},
38+
appRunner: initApp, // Init your App.
39+
);
40+
}
41+
```
42+
43+
## Verify
44+
45+
This snippet captures an intentional error, so you can test that everything is working as soon as you set it up:
46+
47+
```dart
48+
import 'package:logging/logging.dart';
49+
50+
void main() async {
51+
final log = Logger('MyAwesomeLogger');
52+
53+
log.info('a breadcrumb!');
54+
55+
try {
56+
throw Exception();
57+
} catch (error, stackTrace) {
58+
log.severe('an error!', error, stackTrace);
59+
}
60+
}
61+
```
62+
63+
<Note>
64+
65+
Learn more about manually capturing an error or message, in our <PlatformLink to="/usage/">Usage documentation</PlatformLink>.
66+
67+
</Note>
68+
69+
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.

0 commit comments

Comments
 (0)