-
-
Notifications
You must be signed in to change notification settings - Fork 278
enh(internal): debug log api #3425
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
Conversation
…gging This commit adds a new `SentryDebugLogger` class to provide a lightweight, isolate-compatible logging solution for the Sentry SDK. The logger supports various log levels and can be configured for each isolate. Additionally, it integrates with `SentryOptions` to enable logging based on the debug flag and diagnostic level. The existing `IsolateLogger` has been removed in favor of this new implementation, streamlining the logging process across the SDK. - Added `SentryDebugLogger` for structured logging. - Updated `SentryOptions` to configure the logger based on debug settings. - Replaced instances of `IsolateLogger` with `SentryDebugLogger` in relevant files. - Added unit tests for the new logger functionality.
This commit removes a debug logger warning message from the Sentry class during initialization. The change helps to clean up the logging output and streamline the initialization process without affecting functionality.
…ments This commit updates the documentation for the `SentryDebugLogger` to reflect the correct variable name in the example and adds a note emphasizing that each package should have at least one top-level instance of the logger. This enhances clarity for users implementing the logger in their applications.
🚨 Detected changes in high risk code 🚨High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:
|
… logger documentation This commit removes the unused import of the debug logger from the Sentry class and adds an internal annotation to the `SentryDebugLogger` in the debug logger file. Additionally, a comment is added in the isolate worker to suppress a lint warning related to the internal member usage, improving code clarity and maintainability.
…ns.dart This commit removes the unused import of the debug logger from the `sentry_options.dart` file, contributing to cleaner code and improved maintainability.
Android Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 192b44c | 472.26 ms | 477.34 ms | 5.08 ms |
| 640ad0c | 466.00 ms | 552.67 ms | 86.67 ms |
| c26ed0a | 465.52 ms | 476.38 ms | 10.86 ms |
| 7b21e8b | 467.74 ms | 466.24 ms | -1.50 ms |
| a10aff4 | 488.19 ms | 515.02 ms | 26.83 ms |
| e04b24b | 504.72 ms | 516.43 ms | 11.71 ms |
| 827bf09 | 475.40 ms | 547.14 ms | 71.74 ms |
| 6ba4675 | 499.80 ms | 632.43 ms | 132.63 ms |
| 75284dc | 512.39 ms | 530.87 ms | 18.48 ms |
| 2b5e090 | 437.21 ms | 467.14 ms | 29.93 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 192b44c | 13.93 MiB | 14.93 MiB | 1.00 MiB |
| 640ad0c | 6.54 MiB | 7.69 MiB | 1.15 MiB |
| c26ed0a | 13.93 MiB | 14.93 MiB | 1.00 MiB |
| 7b21e8b | 13.93 MiB | 15.00 MiB | 1.06 MiB |
| a10aff4 | 13.93 MiB | 15.06 MiB | 1.13 MiB |
| e04b24b | 13.93 MiB | 15.00 MiB | 1.06 MiB |
| 827bf09 | 6.54 MiB | 7.53 MiB | 1015.27 KiB |
| 6ba4675 | 6.54 MiB | 7.53 MiB | 1015.26 KiB |
| 75284dc | 13.93 MiB | 14.93 MiB | 1.00 MiB |
| 2b5e090 | 13.93 MiB | 15.06 MiB | 1.13 MiB |
Previous results on branch: enh/debug-logging
Startup times
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 3b8e07f | 376.26 ms | 372.73 ms | -3.52 ms |
| a755903 | 534.69 ms | 557.56 ms | 22.88 ms |
| 0b59cbd | 361.38 ms | 351.70 ms | -9.68 ms |
| cd107e8 | 434.74 ms | 478.64 ms | 43.90 ms |
| 3c78396 | 428.80 ms | 427.57 ms | -1.23 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 3b8e07f | 13.93 MiB | 15.18 MiB | 1.25 MiB |
| a755903 | 13.93 MiB | 15.18 MiB | 1.25 MiB |
| 0b59cbd | 13.93 MiB | 15.18 MiB | 1.25 MiB |
| cd107e8 | 13.93 MiB | 15.18 MiB | 1.25 MiB |
| 3c78396 | 13.93 MiB | 15.18 MiB | 1.25 MiB |
iOS Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 8775665 | 1234.17 ms | 1230.04 ms | -4.13 ms |
| 3615e19 | 1225.02 ms | 1234.57 ms | 9.55 ms |
| a69a51f | 1231.73 ms | 1233.15 ms | 1.42 ms |
| 2b5e090 | 1257.04 ms | 1258.07 ms | 1.02 ms |
| a5b28db | 1260.16 ms | 1260.08 ms | -0.08 ms |
| 75284dc | 1254.81 ms | 1262.28 ms | 7.46 ms |
| 2cf9161 | 1248.33 ms | 1266.55 ms | 18.22 ms |
| 9b99523 | 1256.06 ms | 1270.33 ms | 14.27 ms |
| 8541716 | 1270.18 ms | 1271.80 ms | 1.62 ms |
| e45c0e1 | 1269.08 ms | 1278.83 ms | 9.75 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 8775665 | 5.53 MiB | 6.02 MiB | 502.13 KiB |
| 3615e19 | 7.86 MiB | 9.44 MiB | 1.58 MiB |
| a69a51f | 5.53 MiB | 6.01 MiB | 487.38 KiB |
| 2b5e090 | 5.53 MiB | 6.00 MiB | 485.10 KiB |
| a5b28db | 5.53 MiB | 6.02 MiB | 501.31 KiB |
| 75284dc | 5.53 MiB | 5.97 MiB | 453.77 KiB |
| 2cf9161 | 7.86 MiB | 9.44 MiB | 1.58 MiB |
| 9b99523 | 7.86 MiB | 9.44 MiB | 1.58 MiB |
| 8541716 | 5.53 MiB | 6.00 MiB | 479.96 KiB |
| e45c0e1 | 7.86 MiB | 9.44 MiB | 1.58 MiB |
Previous results on branch: enh/debug-logging
Startup times
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| bfd482f | 1254.52 ms | 1256.33 ms | 1.81 ms |
| 3b8e07f | 1260.80 ms | 1261.63 ms | 0.83 ms |
| a755903 | 1234.16 ms | 1232.74 ms | -1.41 ms |
| 0b59cbd | 1268.60 ms | 1257.09 ms | -11.52 ms |
| 3c78396 | 1263.98 ms | 1264.14 ms | 0.16 ms |
| cd107e8 | 1243.78 ms | 1255.02 ms | 11.25 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| bfd482f | 5.53 MiB | 5.96 MiB | 443.38 KiB |
| 3b8e07f | 5.53 MiB | 5.96 MiB | 444.18 KiB |
| a755903 | 5.53 MiB | 5.96 MiB | 443.39 KiB |
| 0b59cbd | 5.53 MiB | 5.96 MiB | 443.39 KiB |
| 3c78396 | 5.53 MiB | 5.96 MiB | 443.39 KiB |
| cd107e8 | 5.53 MiB | 5.96 MiB | 443.44 KiB |
This commit updates the example usage in the `SentryDebugLogger` documentation to reflect the correct variable name, enhancing clarity for users implementing the logger in their applications.
… methods This commit simplifies the `SentryDebugLogger` class by removing the unused `category` parameter from the `debug`, `info`, `warning`, `error`, and `fatal` logging methods. This change enhances code clarity and reduces unnecessary complexity in the logging interface.
This commit removes the test case that checks logging with a category parameter from the `debug_logger_test.dart` file. This change aligns with the recent refactor of the `SentryDebugLogger` class, which eliminated the unused category parameter, thereby enhancing the clarity and relevance of the test suite.
packages/flutter/lib/src/native/java/android_replay_recorder.dart
Outdated
Show resolved
Hide resolved
This commit updates the logging statements in the `_AndroidReplayHandler` class to include the debug name from the configuration. This change improves the clarity of log messages by providing context for unexpected messages and payload types, aiding in debugging and monitoring efforts.
… conventions This commit refactors the `debug_logger_test.dart` file by renaming test groups for clarity and adding new tests to verify the behavior of `SentryOptions.debug` and `SentryOptions.diagnosticLevel`. The changes improve the organization and comprehensiveness of the test suite, ensuring better validation of the `SentryDebugLogger` configuration and logging functionality.
…nostic level handling This commit refactors the `SentryOptions` class to enhance the configuration of the debug logger. The `diagnosticLevel` setter now updates the logger's minimum level dynamically, ensuring that changes to the diagnostic level are reflected immediately. Additionally, the debug logger configuration is encapsulated in a private method for better organization and clarity.
| /// debugLogger.warning('My Message') | ||
| ///``` | ||
| @internal | ||
| class SentryDebugLogger { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think SentryInternalLogger would be a more appropriate name.
|
|
||
| void debug( | ||
| String message, { | ||
| Object? error, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a case where we would log an error + stacktrace as debug? Same for info and probably also warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm not sure, just added it for consistency
…r and enhance logging functionality This commit refactors the logging mechanism by replacing the `SentryDebugLogger` with the new `SentryInternalLogger` across the codebase. The `SentryInternalLogger` provides improved logging capabilities, including compile-time constants for release, profile, and debug modes, ensuring better tree-shaking and performance. Additionally, the associated tests have been updated to validate the new logger's behavior, enhancing overall logging clarity and maintainability.
…odebase This commit removes the `SentryDebugLogger` class and its associated import from `sentry_options.dart`, streamlining the logging functionality in the Sentry SDK. This change is part of the ongoing effort to enhance the logging mechanism by transitioning to the `SentryInternalLogger`, which offers improved capabilities and performance.
…SentryInternalLogger This commit modifies the `SentryOptions` class to replace calls to the deprecated `_configureDebugLogger` method with `_configureInternalLogger`. This change aligns with the recent transition to the `SentryInternalLogger`, ensuring consistent logging configuration and improving overall code clarity.
This commit renames the `debugLogger` to `internalLogger` across the codebase, including tests and various components. This change aligns with the recent transition to the `SentryInternalLogger`, ensuring consistent naming and improving clarity in the logging functionality.
packages/flutter/lib/src/native/java/android_replay_recorder.dart
Outdated
Show resolved
Hide resolved
…ces to internalLogger This commit removes the test for the `debugLogger` constant in `internal_logger_test.dart` and updates references from `debugLogger` to `internalLogger` in the `_AndroidEnvelopeHandler` and `_AndroidReplayHandler` classes. These changes ensure consistency in the logging implementation and align with the recent transition to the `SentryInternalLogger`.
This commit relocates the `_defaultLogOutput` method into the `SentryInternalLogger` class, enhancing the organization of the logging functionality. This change improves code clarity and aligns with the ongoing refactor to streamline the logging mechanism within the Sentry SDK.
This commit enhances the error logging format in the `isolate_worker.dart` file by improving the readability of the log statement. The changes ensure that the error and stack trace are clearly separated, contributing to better debugging and monitoring of isolate message handling failures.
📜 Description
Improves the debug logging dx
💡 Motivation and Context
Currently the debug logging api is tied to the options which has few caveats
New design:
final debugLogger = SentryDebugLogger('sentry.dio')that is then used within the dio packagedebugLoggerinstance, you only need to runSentryDebugLogger.configurein the new isolate💚 How did you test it?
Manual and unit test
🔮 Next steps
Step-by-step replace existing API
#skip-changelog