refactor(logging): Reduce log noise by lowering severity of common errors#4591
Merged
Conversation
…rors
This commit refactors the application's logging to reduce noise in error tracking services like Crashlytics. Many common and expected exceptions, such as those occurring during device disconnections (Bluetooth, USB, TCP), are now logged as warnings (`Warn`) instead of errors (`Error`). This helps to focus on actionable, unexpected errors.
Additionally, a fix is implemented for a map clustering issue and error message reporting is enhanced.
Specific changes include:
- **Error Logging Severity:**
- Changed log level from `Error` to `Warn` for common exceptions in:
- `PacketHandler` (RadioNotConnectedException)
- `SerialConnectionImpl` (USB disconnection IOExceptions)
- `SerialInterface` (serial errors on disconnect)
- `TCPInterface` (TCP write/flush errors on disconnect)
- `MQTTRepository` (publish errors when disconnected)
- `CurrentlyConnectedInfo` (RSSI read failures on disconnect)
- `BTScanModel` (flaky Bluetooth bonding failures)
- Changed `ignoreException` to log at `Warn` level by default.
- Updated the `ServiceRepository.setErrorMessage` method to accept a `Severity` parameter, defaulting to `Error`, allowing callers to specify the importance of a user-facing error message.
- **Map Clustering Fix:**
- Fixed a crash in the Google Maps clustering by propagating the `LifecycleOwner` and `SavedStateRegistryOwner` from the current composable to the root view. This ensures the internally created `ComposeView` can find them.
- Added the `androidx.savedstate:savedstate-compose` dependency to support this fix.
- **MQTT Stability:**
- Improved the MQTT disconnect logic to prevent crashes by checking if the client is connected before attempting to disconnect and safely handling close operations.
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This commit refactors the application's logging to reduce noise in error tracking services like Crashlytics. Many common and expected exceptions, such as those occurring during device disconnections (Bluetooth, USB, TCP), are now logged as warnings (
Warn) instead of errors (Error). This helps to focus on actionable, unexpected errors.Additionally, a fix is implemented for a map clustering issue and error message reporting is enhanced.
Specific changes include:
Error Logging Severity:
ErrortoWarnfor common exceptions in: -PacketHandler(RadioNotConnectedException) -SerialConnectionImpl(USB disconnection IOExceptions) -SerialInterface(serial errors on disconnect) -TCPInterface(TCP write/flush errors on disconnect) -MQTTRepository(publish errors when disconnected) -CurrentlyConnectedInfo(RSSI read failures on disconnect) -BTScanModel(flaky Bluetooth bonding failures)ignoreExceptionto log atWarnlevel by default.ServiceRepository.setErrorMessagemethod to accept aSeverityparameter, defaulting toError, allowing callers to specify the importance of a user-facing error message.Map Clustering Fix:
LifecycleOwnerandSavedStateRegistryOwnerfrom the current composable to the root view. This ensures the internally createdComposeViewcan find them.androidx.savedstate:savedstate-composedependency to support this fix.MQTT Stability: