Skip to content

Commit 4bf6552

Browse files
authored
Add logs docs for Dart/Flutter (#13768)
Adds docs for logs on Dart/Flutter
1 parent e5ae44c commit 4bf6552

File tree

10 files changed

+138
-5
lines changed

10 files changed

+138
-5
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
title: Set Up Logs
3+
sidebar_title: Logs
4+
description: "Structured logs allow you to send, view and query logs sent from your applications within Sentry."
5+
sidebar_order: 5755
6+
---
7+
8+
<Include name="feature-stage-beta-logs.mdx" />
9+
10+
With Sentry Structured Logs, you can send text based log information from your applications to Sentry. Once in Sentry, these logs can be viewed alongside relevant errors, searched by text-string, or searched using their individual attributes.
11+
12+
## Requirements
13+
14+
<PlatformContent includePath="logs/requirements" />
15+
16+
## Setup
17+
18+
<PlatformContent includePath="logs/setup" />
19+
20+
## Usage
21+
22+
<PlatformContent includePath="logs/usage" />
23+
24+
## Options
25+
26+
<PlatformContent includePath="logs/options" />
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
title: Set Up Logs
3+
sidebar_title: Logs
4+
description: "Structured logs allow you to send, view and query logs sent from your applications within Sentry."
5+
sidebar_order: 5755
6+
---
7+
8+
<Include name="feature-stage-beta-logs.mdx" />
9+
10+
With Sentry Structured Logs, you can send text based log information from your applications to Sentry. Once in Sentry, these logs can be viewed alongside relevant errors, searched by text-string, or searched using their individual attributes.
11+
12+
## Requirements
13+
14+
<PlatformContent includePath="logs/requirements" />
15+
16+
## Setup
17+
18+
<PlatformContent includePath="logs/setup" />
19+
20+
## Usage
21+
22+
<PlatformContent includePath="logs/usage" />
23+
24+
## Options
25+
26+
<PlatformContent includePath="logs/options" />

docs/product/explore/logs/getting-started/index.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,11 @@ To set up Sentry Logs, use the links below for supported SDKs. After it's been s
188188
label="Android"
189189
url="/platforms/android/logs/"
190190
/>
191+
- <LinkWithPlatformIcon
192+
platform="dart.flutter"
193+
label="Flutter"
194+
url="/platforms/dart/guides/flutter/logs/"
195+
/>
191196

192197
### Python
193198

@@ -218,11 +223,6 @@ We're actively working on adding Log functionality to additional SDKs. Check out
218223
label="PHP"
219224
url="https://github.com/getsentry/sentry-php/issues/1824"
220225
/>
221-
- <LinkWithPlatformIcon
222-
platform="dart"
223-
label="Dart/Flutter"
224-
url="https://github.com/getsentry/sentry-dart/issues/2915"
225-
/>
226226
- <LinkWithPlatformIcon
227227
platform="cocoa"
228228
label="Cocoa (iOS)"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#### beforeSendLog
2+
3+
To filter logs, or update them before they are sent to Sentry, you can use the `beforeSendLog` option.
4+
5+
```dart
6+
await SentryFlutter.init(
7+
(options) {
8+
options.dsn = "___PUBLIC_DSN___";
9+
options.beforeSendLog = (log) {
10+
if (log.level == SentryLogLevel.info) {
11+
// Filter out all info logs
12+
return null;
13+
}
14+
15+
return log;
16+
};
17+
},
18+
);
19+
```
20+
21+
The `beforeSend` function receives a log object, and should return the log object if you want it to be sent to Sentry, or `null` if you want to discard it.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#### beforeSendLog
2+
3+
To filter logs, or update them before they are sent to Sentry, you can use the `beforeSendLog` option.
4+
5+
```dart
6+
await Sentry.init(
7+
(options) {
8+
options.dsn = "___PUBLIC_DSN___";
9+
options.beforeSendLog = (log) {
10+
if (log.level == SentryLogLevel.info) {
11+
// Filter out all info logs
12+
return null;
13+
}
14+
15+
return log;
16+
};
17+
},
18+
);
19+
```
20+
21+
The `beforeSend` function receives a log object, and should return the log object if you want it to be sent to Sentry, or `null` if you want to discard it.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Logs for Flutter are supported in Sentry Flutter SDK version `9.0.0-RC.3` and above.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Logs for Dart are supported in Sentry Dart SDK version `9.0.0-RC.3` and above.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
To enable logging, you need to initialize the SDK with the `enableLogs` option set to `true`.
2+
3+
```dart
4+
await SentryFlutter.init(
5+
(options) {
6+
options.dsn = "___PUBLIC_DSN___";
7+
// Enable logs to be sent to Sentry
8+
options.enableLogs = true;
9+
},
10+
);
11+
```

platform-includes/logs/setup/dart.mdx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
To enable logging, you need to initialize the SDK with the `enableLogs` option set to `true`.
2+
3+
```dart
4+
await Sentry.init(
5+
(options) {
6+
options.dsn = "___PUBLIC_DSN___";
7+
// Enable logs to be sent to Sentry
8+
options.enableLogs = true;
9+
},
10+
);
11+
```

platform-includes/logs/usage/dart.mdx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Once the feature is enabled on the SDK and the SDK is initialized, you can send logs using the `Sentry.logger` APIs.
2+
3+
The `logger` namespace exposes six methods that you can use to log messages at different log levels: `trace`, `debug`, `info`, `warning`, `error`, and `fatal`.
4+
5+
You can pass additional attributes directly to the logging functions. These properties will be sent to Sentry, and can be searched from within the Logs UI, and even added to the Logs views as a dedicated column.
6+
7+
```dart
8+
Sentry.logger.info("A simple log message");
9+
Sentry.logger.warn("This is a warning log with attributes.", attributes: {
10+
'string-attribute': SentryLogAttribute.string('string'),
11+
'int-attribute': SentryLogAttribute.int(1),
12+
'double-attribute': SentryLogAttribute.double(1.0),
13+
'bool-attribute': SentryLogAttribute.bool(true),
14+
});
15+
```

0 commit comments

Comments
 (0)