Skip to content

feat: setup logging service#6

Merged
koukibadr merged 2 commits into
mainfrom
feat/logger/setup-devtool-logger
Jul 5, 2026
Merged

feat: setup logging service#6
koukibadr merged 2 commits into
mainfrom
feat/logger/setup-devtool-logger

Conversation

@koukibadr

@koukibadr koukibadr commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability when loading and refreshing app skin/theme data.
    • Reduced failures during startup and resume by handling configuration fetch errors more gracefully.
    • Added better fallback behavior when remote theme data is unavailable, helping the app continue using a usable theme.

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@koukibadr, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 53 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: a74bb1ef-e9aa-4bce-937c-8702a4fc59d5

📥 Commits

Reviewing files that changed from the base of the PR and between ddfc3a8 and c92313e.

📒 Files selected for processing (3)
  • lib/services/fskin_logger.dart
  • lib/services/fskin_subscriber.dart
  • lib/services/skin_service.dart
📝 Walkthrough

Walkthrough

This PR introduces a new FskinLogger singleton service wrapping dart:developer logging, then instruments FlutterSkin, FskinSubscriber, and SkinService with log calls at key lifecycle, streaming, and fetch points. The example app's API key was updated and an iOS build phase was removed.

Changes

Fskin Logging Integration

Layer / File(s) Summary
FskinLogger service
lib/services/fskin_logger.dart
New singleton class with logMessage, logWarning, and logError methods wrapping dart:developer log(...) calls.
FlutterSkin lifecycle and theming logging
lib/flutter_skin.dart
Logs apiKey validation errors, stream start, resume/pause lifecycle events, and theme fallback vs. remote decisions.
FskinSubscriber event/retry logging
lib/services/fskin_subscriber.dart
Logs skin update events and retry attempts on stream completion, error, and catch paths.
SkinService fetch logging
lib/services/skin_service.dart
Logs the start of config fetch, non-200 response status codes, and caught exceptions during fetchData.
Example app updates
example/lib/main.dart, example/ios/Runner.xcodeproj/project.pbxproj
Updates the example app's apiKey and removes the "[CP] Embed Pods Frameworks" build phase from the iOS project.

Estimated code review effort: 2 (Simple) | ~12 minutes

Sequence Diagram(s)

sequenceDiagram
  participant App
  participant FlutterSkin
  participant FskinSubscriber
  participant SkinService
  participant FskinLogger

  App->>FlutterSkin: init(apiKey)
  FlutterSkin->>FskinLogger: logError (if apiKey blank)
  FlutterSkin->>FskinSubscriber: _startStream()
  FskinLogger--x FlutterSkin: logMessage(starting stream)
  FskinSubscriber->>FskinLogger: logMessage(skin update event received)
  FskinSubscriber-->>FlutterSkin: onSkinUpdated()
  FlutterSkin->>SkinService: fetchData(apiKey)
  SkinService->>FskinLogger: logMessage(fetching config)
  SkinService-->>FlutterSkin: ProjectConfig or null
  SkinService->>FskinLogger: logError (on failure/non-200)
  FlutterSkin->>FskinLogger: logWarning (fallback theme)
Loading

Possibly related PRs

Poem

A logger hops into the code,
Tracking streams along the road,
"Fskin: fetching!" it will say,
Warnings whispered when colors stray,
With every hop, a trail we keep —
Thump thump, no bug too deep! 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding and wiring up a logging service across the package.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
lib/services/skin_service.dart (1)

33-46: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Exception passed as string interpolation instead of errorObject.

Line 42 logs 'Error fetching skin configuration: $e' as a plain string rather than passing the caught exception via logError's errorObject param. This loses structured error data (type, and stack trace if that param is added) in DevTools' logging view, which is the primary value of using _logger.logError over a plain string message here.

♻️ Proposed fix
-    } catch (e) {
-      _logger.logError('Error fetching skin configuration: $e');
+    } catch (e, stackTrace) {
+      _logger.logError(
+        'Error fetching skin configuration',
+        errorObject: e,
+      );
       return null;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/services/skin_service.dart` around lines 33 - 46, The catch block in
SkinService.fetchSkinConfiguration is logging the exception as plain string
interpolation instead of using logError’s errorObject parameter. Update the
error handling in fetchSkinConfiguration so the caught exception is passed as
structured error data to _logger.logError, keeping the message descriptive while
preserving the exception type and any available stack-trace information for
DevTools.
lib/flutter_skin.dart (1)

75-89: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Missing log when neither remote colors nor fallback theme exist.

toThemeData now logs on the fallback path (line 81) and the remote-theme path (line 85), but the colors == null && fallbackTheme == null branch falls through to return null (line 88) with no log entry. This silently drops the "no theme available" case from observability, which is arguably the most useful case to log.

♻️ Proposed fix
     if (colors == null) {
       if (fallbackTheme != null) {
         _logger.logWarning('No active theme found. Returning fallback theme.');
         return fallbackTheme;
       }
+      _logger.logWarning('No active theme and no fallback theme provided. Returning null.');
     } else {
       _logger.logMessage('Active theme found. Returning remote theme.');
       return remoteTheme;
     }
     return null;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/flutter_skin.dart` around lines 75 - 89, Add logging for the
no-theme-available case in toThemeData: when
FskinRemoteConfig.projectConfig.skin.colors is null and fallbackTheme is also
null, emit a warning before returning null. Keep the existing logs for the
fallbackTheme and remoteTheme branches, and update the control flow in
toThemeData so every exit path is observable.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@example/lib/main.dart`:
- Around line 8-9: The example app in main.dart is committing a real apiKey as
plaintext, so replace the hardcoded secret with a non-sensitive placeholder or
load it from an untracked runtime source such as a dart-define or
environment-based config. Update the example initialization that passes apiKey
so it no longer embeds a live credential in source control, and rotate the
exposed key on the provider side.

In `@lib/services/fskin_logger.dart`:
- Around line 21-29: The `logError` method in `FskinLogger` drops
`dart:developer`’s `stackTrace`, so update its signature to accept and forward a
`stackTrace` parameter alongside `errorObject`. Pass that stack trace through to
the `log(...)` call so diagnostics preserve full exception context. Then update
the call sites in `fskin_subscriber.dart` and `skin_service.dart` to supply the
caught stack trace when they invoke `logError`.

In `@lib/services/fskin_subscriber.dart`:
- Around line 38-58: The retry logging in FSkinSubscriber is dropping the real
exception because both the Stream.listen onError handler and the future
catchError callback ignore the error value. Update the error handling in
FSkinSubscriber so the caught error is forwarded to _logger.logError via the
errorObject argument, and include stackTrace too if the logger API supports it;
keep the retry behavior unchanged in the onError and catchError paths.

---

Outside diff comments:
In `@lib/flutter_skin.dart`:
- Around line 75-89: Add logging for the no-theme-available case in toThemeData:
when FskinRemoteConfig.projectConfig.skin.colors is null and fallbackTheme is
also null, emit a warning before returning null. Keep the existing logs for the
fallbackTheme and remoteTheme branches, and update the control flow in
toThemeData so every exit path is observable.

In `@lib/services/skin_service.dart`:
- Around line 33-46: The catch block in SkinService.fetchSkinConfiguration is
logging the exception as plain string interpolation instead of using logError’s
errorObject parameter. Update the error handling in fetchSkinConfiguration so
the caught exception is passed as structured error data to _logger.logError,
keeping the message descriptive while preserving the exception type and any
available stack-trace information for DevTools.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8ce24131-aa4e-4a3d-906f-c81b92bd58cf

📥 Commits

Reviewing files that changed from the base of the PR and between eb963c6 and ddfc3a8.

📒 Files selected for processing (6)
  • example/ios/Runner.xcodeproj/project.pbxproj
  • example/lib/main.dart
  • lib/flutter_skin.dart
  • lib/services/fskin_logger.dart
  • lib/services/fskin_subscriber.dart
  • lib/services/skin_service.dart
💤 Files with no reviewable changes (1)
  • example/ios/Runner.xcodeproj/project.pbxproj

Comment thread example/lib/main.dart
Comment thread lib/services/fskin_logger.dart
Comment thread lib/services/fskin_subscriber.dart
@koukibadr koukibadr merged commit 5ed73a9 into main Jul 5, 2026
2 checks passed
@koukibadr koukibadr deleted the feat/logger/setup-devtool-logger branch July 5, 2026 06:30
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.

1 participant