feat: Enhance custom Logger with error handling and persistence features#31
Merged
Conversation
…and WasmJs repositories
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a cross-platform diagnostics/logging system with configurable log levels, optional persisted log storage, and user-facing export/clear controls, integrating into Settings and platform-specific implementations (Android/JVM/Wasm).
Changes:
- Added a new
Loggerexpect/actual API with log level filtering, optional persistence, andLogExportResultfor export outcomes. - Extended
SettingsRepositorywith reactive log-level and persistence settings, wiring them through Settings UI andAppstartup. - Implemented Android/JVM persisted logging + export mechanisms (FileProvider share on Android, file chooser export on JVM), and updated AutoSync to use the new logger.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| composeApp/src/commonMain/kotlin/io/github/smiling_pixel/util/Logger.kt | Defines the cross-platform Logger API, log levels, export result model, and helper extensions. |
| composeApp/src/androidMain/kotlin/io/github/smiling_pixel/util/Logger.android.kt | Android logger implementation with persistence, rotation, and share-sheet export via FileProvider. |
| composeApp/src/jvmMain/kotlin/io/github/smiling_pixel/util/Logger.jvm.kt | JVM logger implementation with persistence, rotation, and export via save dialog. |
| composeApp/src/wasmJsMain/kotlin/io/github/smiling_pixel/util/Logger.wasmJs.kt | Wasm/JS logger implementation with console output and unsupported export/clear behavior. |
| composeApp/src/commonMain/kotlin/io/github/smiling_pixel/preference/SettingsRepository.kt | Adds log-level and persistence settings to the shared settings interface. |
| composeApp/src/nonWebMain/kotlin/io/github/smiling_pixel/preference/DataStoreSettingsRepository.kt | Persists log settings for non-web platforms via DataStore. |
| composeApp/src/wasmJsMain/kotlin/io/github/smiling_pixel/preference/SettingsRepository.wasmJs.kt | Persists log settings for web via localStorage. |
| composeApp/src/commonMain/kotlin/io/github/smiling_pixel/screens/SettingsScreen.kt | Adds a Diagnostics section (log level, persistence toggle, export/clear actions). |
| composeApp/src/commonMain/kotlin/io/github/smiling_pixel/App.kt | Applies logger settings reactively at runtime from SettingsRepository flows. |
| composeApp/src/androidMain/AndroidManifest.xml | Adds FileProvider for securely sharing exported log files. |
| composeApp/src/androidMain/res/xml/log_export_paths.xml | Declares FileProvider paths for log export (cache log_exports/). |
| composeApp/src/androidMain/README.md | Documents Android build/manifest requirements for log export. |
| composeApp/src/androidMain/kotlin/io/github/smiling_pixel/sync/AutoSync.android.kt | Switches AutoSync error logging to the new Logger API. |
| composeApp/src/jvmMain/kotlin/io/github/smiling_pixel/sync/AutoSync.jvm.kt | Switches AutoSync error logging to the new Logger API. |
| composeApp/build.gradle.kts | Adds AndroidX Core KTX dependency required for FileProvider integration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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 pull request introduces a comprehensive diagnostics and logging system to the application, focusing on configurable log levels, persistent log storage, and user-facing log export/clear features. The changes span both core logic and Android-specific integration, enabling users to control logging behavior and export logs for troubleshooting directly from the app's settings.
Diagnostics and Logging Functionality
LoggerAPI with support for configurable log levels, persistent log storage, and log export/clear operations. The Android implementation persists logs to local storage, supports log rotation, and uses the Android share sheet for exporting logs. (composeApp/src/commonMain/kotlin/io/github/smiling_pixel/util/Logger.kt,composeApp/src/androidMain/kotlin/io/github/smiling_pixel/util/Logger.android.kt) [1] [2]LogExportResultsealed interface to standardize log export outcomes across platforms.AutoSync.android.ktmodule to use the newLoggerfor error reporting instead of direct Android logging. [1] [2]User Settings and UI Integration
SettingsRepositoryinterface to support reactive flows and setters for log level and log persistence, allowing users to configure these diagnostics settings.SettingsScreenUI with a new Diagnostics section, enabling users to select log level, toggle log persistence, export logs, and clear logs. The UI provides immediate feedback on diagnostics actions. [1] [2]Appcomposable to reactively apply user-selected log settings to theLoggerat runtime.Android Platform Integration
FileProviderto the manifest and resources, enabling secure sharing of exported log files. [1] [2] [3]These changes collectively provide robust diagnostics capabilities, improve troubleshooting, and empower users and developers to control and access application logs safely.