Skip to content

Commit 185594c

Browse files
authored
feat(godot): Promote Logs to generally available in Godot SDK (#15772)
1 parent 82418d5 commit 185594c

File tree

5 files changed

+43
-11
lines changed

5 files changed

+43
-11
lines changed

docs/platforms/godot/configuration/options.mdx

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,24 @@ This option is turned on by default.
163163

164164
</SdkOption>
165165

166-
## Error Logger Options
166+
## Logging Options
167+
168+
<SdkOption name="enable_logs" type="bool" defaultValue="true" availableSince="1.2.0">
169+
170+
If `true`, enables Sentry structured logs functionality, allowing you to use dedicated logging APIs through
171+
`SentrySDK.logger`, and Godot's built-in log messages are automatically captured and sent to Sentry Logs.
172+
Use `logger_enabled` and other `logger_*` options to control how Godot's error messages and log output
173+
(including `print()` statements) are captured and processed by Sentry.
174+
175+
This option is turned on by default.
176+
177+
</SdkOption>
178+
179+
## Godot Logger Options
167180

168181
<SdkOption name="logger_enabled" type="bool" defaultValue="true">
169182

170-
If `true`, the SDK will capture logged errors as events and/or breadcrumbs, as defined by `logger_event_mask` and `logger_breadcrumb_mask` options. Crashes are always captured.
183+
If `true`, the SDK will capture logged errors as events, logs and/or breadcrumbs, as defined by `logger_event_mask` and `logger_breadcrumb_mask` options. Crashes are always captured. See also `enable_logs` option.
171184

172185
This option is turned on by default.
173186

@@ -255,7 +268,7 @@ These options can be used to hook the SDK in various ways to customize the repor
255268
The callbacks you set as hooks will be called on the thread where the event happened. So you can only use
256269
thread-safe APIs and only use Godot-specific APIs after you've checked that you're on the main thread.
257270

258-
<SdkOption name="before_send" type="function">
271+
<SdkOption name="before_send" type="Callable">
259272

260273
If assigned, this callback runs before an event is sent to Sentry. You can only set it [programmatically](#programmatic-configuration). It takes `SentryEvent` as a parameter and returns either the same event object, with or without modifications, or `null` to skip reporting the event. This can be used, for instance, for stripping PII before sending.
261274

@@ -274,7 +287,7 @@ func _before_send(event: SentryEvent) -> SentryEvent:
274287

275288
</SdkOption>
276289

277-
<SdkOption name="before_capture_screenshot" type="function">
290+
<SdkOption name="before_capture_screenshot" type="Callable">
278291

279292
If assigned, this callback runs before a screenshot is captured. You can only set it [programmatically](#programmatic-configuration). It takes `SentryEvent` as a parameter and returns `false` to skip capturing the screenshot, or `true` to capture the screenshot.
280293

@@ -286,3 +299,22 @@ func _before_capture_screenshot(event: SentryEvent) -> bool:
286299
```
287300

288301
</SdkOption>
302+
303+
<SdkOption name="before_send_log" type="Callable" availableSince="1.2.0">
304+
305+
If assigned, this callback will be called before sending a log message to Sentry.
306+
It can be used to modify the log message or prevent it from being sent.
307+
308+
```GDScript
309+
func _before_send_log(log_entry: SentryLog) -> SentryLog:
310+
# Filter junk.
311+
if log_entry.body == "Junk message":
312+
return null
313+
# Remove sensitive information from log messages.
314+
log_entry.body = log_entry.body.replace("Bruno", "REDACTED")
315+
# Add custom attributes.
316+
log_entry.set_attribute("current_scene", current_scene.name)
317+
return log_entry
318+
```
319+
320+
</SdkOption>

platform-includes/getting-started-primer/godot.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Our SDK for Godot Engine builds on top of existing Sentry SDKs, extending them w
1010
- Automatically capture Godot runtime errors, such as script and shader errors
1111
- GDScript stack traces with optional [local and member variable](/platforms/godot/configuration/options/#logger_include_variables) information
1212
- Include surrounding script source code with events when available at runtime
13-
- Automatic breadcrumbs for console output, such as `print()` statements
13+
- [Structured Logs](/platforms/godot/logs/) that automatically capture console output like `print()` statements and connect to your traces with searchable attributes
1414
- [Enrich events](/platforms/godot/enriching-events/) with tags, breadcrumbs, contexts, and attachments
1515
- Information about user configuration like GPU, CPU, platform and such
1616
- [Filter and customize events](/platforms/godot/data-management/sensitive-data/#scrubbing-data) in `before_send` callback (in GDScript)

platform-includes/logs/options/godot.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ To filter logs, or update them before they are sent to Sentry, you can use the `
44

55
```GDScript
66
SentrySDK.init(func(options: SentryOptions) -> void:
7-
options.experimental.enable_logs = true
8-
options.experimental.before_send_log = _before_send_log
7+
options.enable_logs = true
8+
options.before_send_log = _before_send_log
99
)
1010
1111
func _before_send_log(log_entry: SentryLog) -> SentryLog:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
Logs for Godot Engine are supported in Sentry Godot SDK version `1.1.0` and above.
2+
Starting with version `1.2.0`, the feature is generally available and enabled by default.

platform-includes/logs/setup/godot.mdx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ To enable logging in your Godot project, you need to configure the Sentry SDK wi
22

33
### Project Settings Configuration
44

5-
1. Open **Project Settings** in Godot, and navigate to **Sentry > Experimental**.
6-
2. Turn on the **Enable Logs** option.
5+
Structured logs are enabled by default. If you want to modify this setting, navigate to **Project Settings** in Godot, then go to **Sentry > Options** and adjust the **Enable Logs** option as needed.
76

87
### Programmatic Configuration
98

10-
Alternatively, you can enable logs programmatically when initializing the SDK:
9+
Structured logs are enabled by default. If needed, you can disable logs programmatically when initializing the SDK:
1110

1211
```GDScript
1312
SentrySDK.init(func(options: SentryOptions) -> void:
14-
options.experimental.enable_logs = true
13+
options.enable_logs = false
1514
)
1615
```

0 commit comments

Comments
 (0)