Skip to content
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

fix: Stacktraces for non-exception events #1965

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

bitsandfoxes
Copy link
Contributor

@bitsandfoxes bitsandfoxes commented Jan 13, 2025

Fixes #1608

This PR restores the functionality of capturing Debug.LogError and provides stacktraces in the resulting event.

Before

Screenshot 2025-01-22 at 11 43 07

After

Screenshot 2025-01-22 at 12 54 51

Implementation Details

In this PR, we split the logging integration into two components:

  • UnityLogHandlerIntegration
  • UnityApplicationLoggingIntegration

The UnityLogHandlerIntegration hooks into the actual log handler and intercepts all logs. This allows us to access the exception object directly in case of Debug.LogException, but comes with notable limitations:

  • We must call string.Format for each log captured as a breadcrumb
  • We lose access to the stacktrace string that was previously available through Application.OnMessageReceived

To address these limitations, we now implement both approaches:

  1. Capturing exceptions via UnityLogHandlerIntegration
  2. Creating breadcrumbs for logs via UnityApplicationLoggingIntegration
  3. Capturing LogErrors via UnityApplicationLoggingIntegration

We create a synthetic exception that parses the stringified stacktrace during capture and generates an event from it.

Known Limitations

Currently, we cannot provide line numbers for these issues. The IL2CPPEventProcessor requires an actually thrown exception to retrieve the necessary images and instruction addresses. In the case of Debug.LogError, no such exception exists.

@bitsandfoxes bitsandfoxes marked this pull request as ready for review January 21, 2025 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Split logging integration from error capturing
2 participants