-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
docs(godot): Structured logging #15287
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| --- | ||
| title: Set Up Logs | ||
| sidebar_title: Logs | ||
| description: "Structured logs allow you to send, view and query logs sent from your applications within Sentry." | ||
| sidebar_order: 5600 | ||
| --- | ||
|
|
||
| With Sentry Structured Logs, you can send text-based log information from your Godot Engine applications to Sentry. Once in Sentry, these logs can be viewed alongside relevant errors, searched by text-string, or searched using their individual attributes. | ||
|
|
||
| ## Requirements | ||
|
|
||
| <PlatformContent includePath="logs/requirements" /> | ||
|
|
||
| ## Setup | ||
|
|
||
| <PlatformContent includePath="logs/setup" /> | ||
|
|
||
| ## Usage | ||
|
|
||
| <PlatformContent includePath="logs/usage" /> | ||
|
|
||
| ## Options | ||
|
|
||
| <PlatformContent includePath="logs/options" /> | ||
|
|
||
| ## Default Attributes | ||
|
|
||
| <PlatformContent includePath="logs/default-attributes" /> | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| <PlatformContent includePath="logs/troubleshooting" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| The Godot SDK automatically sets several default attributes on all log entries to provide context and improve debugging: | ||
|
|
||
| <Include name="logs/default-attributes/core" /> | ||
|
|
||
| <Include name="logs/default-attributes/user-mobile" /> | ||
|
|
||
| <Include name="logs/default-attributes/integration" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| ### before_send_log | ||
|
|
||
| To filter logs, or update them before they are sent to Sentry, you can use the `before_send_log` option. | ||
|
|
||
| ```GDScript | ||
| SentrySDK.init(func(options: SentryOptions) -> void: | ||
| options.experimental.enable_logs = true | ||
| options.experimental.before_send_log = _before_send_log | ||
| ) | ||
|
|
||
| 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 | ||
| ``` | ||
|
|
||
| The `before_send_log` function receives a `SentryLog` object, and should return either the same log object, with or without modifications, or `null` if you want to discard it. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Logs for Godot Engine are supported in Sentry Godot SDK version `1.1.0` and above. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| To enable logging in your Godot project, you need to configure the Sentry SDK with Logs enabled. | ||
|
|
||
| ### Project Settings Configuration | ||
|
|
||
| 1. Open **Project Settings** in Godot, and navigate to **Sentry > Experimental**. | ||
| 2. Turn on the **Enable Logs** option. | ||
|
|
||
| ### Programmatic Configuration | ||
|
|
||
| Alternatively, you can enable logs programmatically when initializing the SDK: | ||
|
|
||
| ```GDScript | ||
| SentrySDK.init(func(options: SentryOptions) -> void: | ||
| options.experimental.enable_logs = true | ||
| ) | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| ### Performance Considerations | ||
|
|
||
| - Logs are sent asynchronously to avoid impacting game performance. | ||
| - Consider disabling debug level logs in production to avoid excessive log volume. | ||
| - `before_send_log` callback is executed synchronously, so keep processing lightweight. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| Once the feature is enabled on the SDK and the SDK is initialized, you can send logs using the `SentrySDK.logger` APIs. | ||
|
|
||
| The `SentrySDK.logger` exposes six methods that you can use to log messages at different log levels: `trace`, `debug`, `info`, `warn`, `error`, and `fatal`. | ||
|
|
||
| ```GDScript | ||
| SentrySDK.logger.trace("Initialized inventory database") | ||
| SentrySDK.logger.debug("Player inventory updated") | ||
| SentrySDK.logger.info("Level loaded successfully") | ||
| SentrySDK.logger.warn("Item configuration not found") | ||
| SentrySDK.logger.error("Failed to save game state") | ||
| SentrySDK.logger.fatal("Inventory data corrupted") | ||
| ``` | ||
|
|
||
| <Alert level="info"> | ||
|
|
||
| Support for log attributes and string interpolation will be added in future releases. | ||
|
|
||
| </Alert> | ||
|
|
||
| ### Godot Logging Integration | ||
|
|
||
| When the feature is enabled, the SDK automatically captures Godot messages, warnings, and errors as logs. You can use `print()`, `push_warning()`, and `push_error()` as usual. These show up as `info`, `warning`, and `error` logs. The SDK also turns runtime errors and warnings into events based on your configuration. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.