Skip to content

refactor(logging): Reduce log noise by lowering severity of common errors#4591

Merged
jamesarich merged 1 commit into
mainfrom
fix/crashlytics
Feb 18, 2026
Merged

refactor(logging): Reduce log noise by lowering severity of common errors#4591
jamesarich merged 1 commit into
mainfrom
fix/crashlytics

Conversation

@jamesarich

@jamesarich jamesarich commented Feb 18, 2026

Copy link
Copy Markdown
Collaborator

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.

…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>
@github-actions github-actions Bot added the bugfix PR tag label Feb 18, 2026
@jamesarich jamesarich marked this pull request as ready for review February 18, 2026 21:01
@jamesarich jamesarich enabled auto-merge February 18, 2026 21:01
@jamesarich jamesarich added this pull request to the merge queue Feb 18, 2026
@codecov

codecov Bot commented Feb 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 39 lines in your changes missing coverage. Please review.
✅ Project coverage is 14.77%. Comparing base (b9ee54a) to head (80ccaf4).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...sville/mesh/repository/usb/SerialConnectionImpl.kt 0.00% 10 Missing ⚠️
...main/java/com/geeksville/mesh/model/BTScanModel.kt 0.00% 8 Missing ⚠️
...eksville/mesh/repository/network/MQTTRepository.kt 0.00% 7 Missing ⚠️
...ava/com/geeksville/mesh/service/MeshMqttManager.kt 0.00% 4 Missing ⚠️
...n/org/meshtastic/core/service/ServiceRepository.kt 0.00% 3 Missing ⚠️
...m/geeksville/mesh/repository/radio/TCPInterface.kt 0.00% 2 Missing ⚠️
.../java/com/geeksville/mesh/service/PacketHandler.kt 0.00% 2 Missing ⚠️
...eeksville/mesh/repository/radio/SerialInterface.kt 0.00% 1 Missing ⚠️
...ava/com/geeksville/mesh/service/MeshDataHandler.kt 0.00% 1 Missing ⚠️
...c/main/java/com/geeksville/mesh/util/Exceptions.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4591   +/-   ##
=======================================
  Coverage   14.77%   14.77%           
=======================================
  Files         429      429           
  Lines       14861    14872   +11     
  Branches     2464     2468    +4     
=======================================
+ Hits         2195     2197    +2     
- Misses      12350    12357    +7     
- Partials      316      318    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Merged via the queue into main with commit f012e38 Feb 18, 2026
10 checks passed
@jamesarich jamesarich deleted the fix/crashlytics branch February 18, 2026 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix PR tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant