Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions docs/platforms/godot/configuration/options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,24 @@ This option is turned on by default.

</SdkOption>

## Error Logger Options
## Logging Options

<SdkOption name="enable_logs" type="bool" defaultValue="true">

If `true`, enables Sentry structured logs functionality, allowing you to use dedicated logging APIs through
`SentrySDK.logger`, and Godot's built-in log messages are automatically captured and sent to Sentry Logs.
Use `logger_enabled` and other `logger_*` options to control how Godot's error messages and log output
(including `print()` statements) are captured and processed by Sentry.

</SdkOption>

## Godot Logger Options

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

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.

This option is turned on by default.
Supported from version `1.1.0` and above, this option is turned on by default starting with version `1.2.0`.

</SdkOption>

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

<SdkOption name="before_send" type="function">
<SdkOption name="before_send" type="Callable">

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.

Expand All @@ -274,7 +285,7 @@ func _before_send(event: SentryEvent) -> SentryEvent:

</SdkOption>

<SdkOption name="before_capture_screenshot" type="function">
<SdkOption name="before_capture_screenshot" type="Callable">

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.

Expand All @@ -286,3 +297,22 @@ func _before_capture_screenshot(event: SentryEvent) -> bool:
```

</SdkOption>

<SdkOption name="before_send_log" type="Callable">

If assigned, this callback will be called before sending a log message to Sentry.
It can be used to modify the log message or prevent it from being sent.

```GDScript
func _before_send_log(log_entry: SentryLog) -> SentryLog:
# Filter junk.
if log_entry.body == "Junk message":
return null
# Remove sensitive information from log messages.
log_entry.body = log_entry.body.replace("Bruno", "REDACTED")
# Add custom attributes.
log_entry.set_attribute("current_scene", current_scene.name)
return log_entry
```

</SdkOption>
4 changes: 2 additions & 2 deletions platform-includes/logs/options/godot.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ To filter logs, or update them before they are sent to Sentry, you can use the `

```GDScript
SentrySDK.init(func(options: SentryOptions) -> void:
options.experimental.enable_logs = true
options.experimental.before_send_log = _before_send_log
options.enable_logs = true
options.before_send_log = _before_send_log
)

func _before_send_log(log_entry: SentryLog) -> SentryLog:
Expand Down
1 change: 1 addition & 0 deletions platform-includes/logs/requirements/godot.mdx
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Logs for Godot Engine are supported in Sentry Godot SDK version `1.1.0` and above.
Starting with version `1.2.0`, the feature is enabled by default.
7 changes: 3 additions & 4 deletions platform-includes/logs/setup/godot.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ To enable logging in your Godot project, you need to configure the Sentry SDK wi

### Project Settings Configuration

1. Open **Project Settings** in Godot, and navigate to **Sentry > Experimental**.
2. Turn on the **Enable Logs** option.
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.

### Programmatic Configuration

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

```GDScript
SentrySDK.init(func(options: SentryOptions) -> void:
options.experimental.enable_logs = true
options.enable_logs = false
)
```
Loading