Skip to content

feat(admin-ui): Migrate Home/Core module to unified logger (#2868)#2869

Open
faisalsiddique4400 wants to merge 2 commits into
mainfrom
admin-ui-issue-2868
Open

feat(admin-ui): Migrate Home/Core module to unified logger (#2868)#2869
faisalsiddique4400 wants to merge 2 commits into
mainfrom
admin-ui-issue-2868

Conversation

@faisalsiddique4400

@faisalsiddique4400 faisalsiddique4400 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

feat(admin-ui): Migrate Home/Core module to unified logger (#2868)

Summary

This PR migrates the Home/Core module to the new unified logging system and replaces all remaining usages of the removed devLogger utility.

The new logger introduces audience-based logging through logger.<level>('dev' | 'prod' | 'both', ...), providing a consistent logging API across the Admin UI while preserving the existing behavior. Calls targeting the dev audience remain gated behind development mode, matching the previous devLogger implementation.

No user-facing behavior changes are introduced.


Fix Summary

  • Removed legacy logging utilities:
    • app/utils/devLogger.ts
    • app/utils/types/DevLoggerTypes.ts
  • Added unified logging infrastructure:
    • app/utils/logger.ts
    • app/utils/types/LoggerTypes.ts
  • Migrated Home/Core module logging to the unified logger
  • Updated core application shell logging
  • Updated layout-level logging
  • Updated Redux core and listener logging
  • Updated shared utility logging
  • Updated Orval interceptor logging
  • Updated plugin loader logging
  • Standardized logging APIs across core modules
  • Preserved development-only logging behavior through the dev audience
  • Improved consistency and maintainability of application diagnostics

Verification

npm run check:all

passes successfully.

  • Verified development-only logs remain gated in development environments
  • Verified production logging behavior remains unchanged
  • Verified core application startup and initialization flows
  • Verified plugin loading and registration flows
  • Verified listener and interceptor logging continues functioning correctly
  • Verified no regressions in Home/Core module functionality

🔗 Ticket

Closes: #2868

Summary by CodeRabbit

  • Refactor

    • Replaced development logger with a unified, environment-aware logging system across the admin UI
    • Enhanced error message handling to include additional response fields for better diagnostics
  • Chores

    • Improved logging infrastructure for consistent error reporting and environment-aware output

Signed-off-by: faisalsiddique4400 <faisalsiddique10886@gmail.com>
@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@faisalsiddique4400, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 18 minutes and 9 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

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.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: a6b4b3b0-cc1d-4e6e-9ea5-5aa0037068f0

📥 Commits

Reviewing files that changed from the base of the PR and between aedb5c0 and d36ebd7.

📒 Files selected for processing (2)
  • admin-ui/app/routes/Apps/Gluu/GluuSessionTimeout.tsx
  • admin-ui/app/routes/License/hooks/useLicenseDetails.ts
📝 Walkthrough

Walkthrough

This PR replaces the devLogger utility with a new unified logger that supports environment-aware routing ('dev', 'prod', 'both'). The new logger is applied consistently across the admin-ui codebase including core app initialization, Redux listeners, UI components, API helpers, and plugin loaders. Error message resolution is enhanced by adding responseMessage field support to ApiErrorResponseBody.

Changes

Unified logger migration across admin-ui

Layer / File(s) Summary
Logger core infrastructure and types
admin-ui/app/utils/types/LoggerTypes.ts, admin-ui/app/utils/logger.ts, admin-ui/app/utils/types/index.ts
New LogArg and LogEnv types defined; logger constant exported with log/warn/error/debug methods that route console output based on environment audience and isDevelopment flag; barrel export updated.
API error message enhancement
admin-ui/app/utils/apiErrorMessage.ts
ApiErrorResponseBody gains optional responseMessage field; resolveApiErrorMessage now prefers responseMessage before message when extracting error strings.
Core app initialization and layout
admin-ui/app/layout/default.tsx, admin-ui/app/i18n.ts, admin-ui/app/components/App/PermissionsPolicyInitializer.tsx
Layout and i18n modules switch to logger; Cedarling policy initializer adds per-attempt retry warnings and final exhaustion error logging.
Theme context and resolution
admin-ui/app/context/theme/themeContext.tsx
Updates extractUserTheme, getInitialTheme, getUserInum, and ThemeProvider useEffect to use logger for initialization/sync error reporting.
Cedarling authorization logging
admin-ui/app/cedarling/hooks/useCedarling.ts
Adds error logging in authorize function catch block, reporting resource id, action label, and error message.
Wizard component warning logging
admin-ui/app/components/Wizard/Wizard.tsx
Switches uncontrolled/controlled usage warning to use logger.warn.
Redux listeners migration
admin-ui/app/redux/listeners/authListener.ts, admin-ui/app/redux/listeners/licenseListener.ts, admin-ui/app/redux/listeners/sessionListener.ts
Auth, license, and session listeners updated to use logger across OAuth2 config/token/session failures, license operations, and logout auditing.
Backend API error logging standardization
admin-ui/app/redux/api/backend-api.ts
All API helper catch blocks now call logger.error('both', ...) with resolveApiErrorMessage, covering configuration, user info, token, policy store, and session endpoints.
AppAuthProvider error logging
admin-ui/app/utils/AppAuthProvider.tsx
Adds error logging in policy store fetch, OIDC issuer config, and user info fetch failure paths using resolved error messages.
Gluu UI components migration
admin-ui/app/routes/Apps/Gluu/*.tsx
GluuAppSidebar, GluuCommitDialog, GluuScriptErrorModal, GluuSessionTimeout, LanguageMenu, ThemeDropdown updated to use logger; plugin menu and commit error handling now include resolved API error messages.
Route hooks and utility functions migration
admin-ui/app/routes/Apps/Profile/hooks/useProfileDetails.ts, admin-ui/app/routes/License/hooks/useLicenseDetails.ts, admin-ui/app/routes/Pages/ByeBye.tsx, admin-ui/app/routes/index.tsx, admin-ui/app/utils/pagingUtils.ts, admin-ui/app/utils/triggerWebhookForFeature.ts
useProfileDetails, useLicenseDetails, ByeBye logout page, routes index, pagingUtils, and webhook utils switch to logger for error/warning reporting.
Plugin loaders and orval interceptors
admin-ui/plugins/PluginMenuResolver.ts, admin-ui/plugins/internal/loadPluginMetadata.ts, admin-ui/orval/interceptors.ts
Plugin metadata loaders and orval interceptors migrate to logger for metadata loading and session recovery/403 cleanup error reporting.
Test mocking updates
admin-ui/orval/__tests__/interceptors.test.ts
Jest mock updated to mock @/utils/logger with log, warn, error, debug as jest.fn() functions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • GluuFederation/flex#2711: Both PRs touch the Cedarling authorization flow in admin-ui/app/cedarling/hooks/useCedarling.ts—the main PR adds logger-based error logging on authorization failures, while the retrieved PR changes the token_authorize request/token structure for multi-issuer authz.
  • GluuFederation/flex#2722: Both PRs modify admin-ui/app/cedarling/hooks/useCedarling.ts in the authorize catch/error-handling path where the main PR adds logger-based error logging and the retrieved PR changes the toMessage typing/call site.

Suggested labels

comp-admin-ui, kind-enhancement

Suggested reviewers

  • duttarnab
  • moabu

Poem

A rabbit hops through logs so bright, 🐰
From devLogger to unified light,
Environment routes now guide the way,
Dev and prod both have their say,
Cleaner errors make debugging right! ✨

🚥 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 PR title clearly and concisely summarizes the main change: migrating the Home/Core module from devLogger to a unified logger.
Linked Issues check ✅ Passed All coding objectives from #2868 are fully met: devLogger removed, unified logger added with new types, and all core module imports updated to use new logger API.
Out of Scope Changes check ✅ Passed All changes are directly aligned with the logger migration scope; no unrelated modifications to Home/Core module functionality or external areas detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch admin-ui-issue-2868

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 and usage tips.

@mo-auto mo-auto added comp-admin-ui Component affected by issue or PR kind-feature Issue or PR is a new feature request labels Jun 8, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Caution

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

⚠️ Outside diff range comments (1)
admin-ui/app/routes/License/hooks/useLicenseDetails.ts (1)

88-93: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Optional: Remove redundant isDevelopment guard.

The new logger.error('dev', ...) API already gates on development mode internally (per PR objectives: "development-only logs remain gated by development mode"). The explicit if (isDevelopment) check is redundant and inconsistent with the migration pattern used in other files in this PR (e.g., useProfileDetails.ts, ByeBye.tsx, index.tsx, pagingUtils.ts), which call logger.error('dev', ...) directly without guards.

♻️ Simplify by removing the redundant guard
-        if (baseAudit) {
-          const audit = {
-            ...baseAudit,
-            action: DELETION,
-            resource: API_LICENSE,
-            message: pendingMessageRef.current,
-          }
-          try {
-            await postUserAction(audit)
-          } catch (e) {
-            if (isDevelopment) {
-              logger.error('dev', 
-                'License reset audit post failed:',
-                e instanceof Error ? e : String(e),
-              )
-            }
-          }
-        }
+        if (baseAudit) {
+          const audit = {
+            ...baseAudit,
+            action: DELETION,
+            resource: API_LICENSE,
+            message: pendingMessageRef.current,
+          }
+          try {
+            await postUserAction(audit)
+          } catch (e) {
+            logger.error('dev', 
+              'License reset audit post failed:',
+              e instanceof Error ? e : String(e),
+            )
+          }
+        }
🤖 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 `@admin-ui/app/routes/License/hooks/useLicenseDetails.ts` around lines 88 - 93,
Remove the redundant development-mode guard: delete the surrounding if
(isDevelopment) { ... } and call logger.error('dev', 'License reset audit post
failed:', e instanceof Error ? e : String(e)) directly so the logger's internal
dev gating is used; look for the isDevelopment check and the logger.error('dev',
...) call inside useLicenseDetails (the catch block that logs the "License reset
audit post failed" error) and keep the same error argument handling (e
instanceof Error ? e : String(e)).
🤖 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 `@admin-ui/app/routes/Apps/Gluu/GluuAppSidebar.tsx`:
- Around line 167-169: The catch in loadMenus currently logs and swallows errors
(logger.error(... resolveApiErrorMessage)) which leaves pluginMenus empty and
isReady false causing an infinite loader; either re-throw the error so the
existing ErrorBoundary (ErrorBoundary) can handle it (remove the catch or add
`throw error` after logging), or set a component error state (e.g.,
pluginMenusError via useState) inside the catch and mark loading complete so the
render can show an error message with a retry button that calls loadMenus again;
update the render logic that checks isReady/pluginMenus to display the error UI
when pluginMenusError is set and wire the retry to the loadMenus function.

In `@admin-ui/app/routes/Apps/Gluu/GluuSessionTimeout.tsx`:
- Line 57: The logout error is currently being logged only to the 'dev' channel
via logger.error in GluuSessionTimeout; update the logger.error call used in the
logout error handling (logger.error(...)) to log to both environments (use
'both' as the target) and keep the same error payload (err instanceof Error ?
err : String(err)) so production will also record these security-sensitive
failures for monitoring and audit.

In `@admin-ui/app/routes/License/hooks/useLicenseDetails.ts`:
- Line 17: Remove the now-unused isDevelopment import from useLicenseDetails.ts:
locate the import statement "import { isDevelopment } from '`@/utils/env`'" and
delete it so the file no longer imports isDevelopment when its guards were
removed.
- Around line 107-109: Remove the redundant isDevelopment guard around the
logger call in useLicenseDetails.ts: inside the reset-license/error handling
block where you currently have "if (isDevelopment && error != null) {
logger.error('dev', 'License reset failed:', error) }", drop the outer
isDevelopment check and simply call logger.error('dev', 'License reset failed:',
error) (you may also omit the null check since logging a null/undefined error is
harmless); this keeps the development-only logging behavior delegated to logger
and simplifies the conditional.

---

Outside diff comments:
In `@admin-ui/app/routes/License/hooks/useLicenseDetails.ts`:
- Around line 88-93: Remove the redundant development-mode guard: delete the
surrounding if (isDevelopment) { ... } and call logger.error('dev', 'License
reset audit post failed:', e instanceof Error ? e : String(e)) directly so the
logger's internal dev gating is used; look for the isDevelopment check and the
logger.error('dev', ...) call inside useLicenseDetails (the catch block that
logs the "License reset audit post failed" error) and keep the same error
argument handling (e instanceof Error ? e : String(e)).
🪄 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: db4fba1d-62dd-4294-9552-4f543bf2465a

📥 Commits

Reviewing files that changed from the base of the PR and between e2f257a and aedb5c0.

📒 Files selected for processing (31)
  • admin-ui/app/cedarling/hooks/useCedarling.ts
  • admin-ui/app/components/App/PermissionsPolicyInitializer.tsx
  • admin-ui/app/components/Wizard/Wizard.tsx
  • admin-ui/app/context/theme/themeContext.tsx
  • admin-ui/app/i18n.ts
  • admin-ui/app/layout/default.tsx
  • admin-ui/app/redux/api/backend-api.ts
  • admin-ui/app/redux/listeners/authListener.ts
  • admin-ui/app/redux/listeners/licenseListener.ts
  • admin-ui/app/redux/listeners/sessionListener.ts
  • admin-ui/app/routes/Apps/Gluu/GluuAppSidebar.tsx
  • admin-ui/app/routes/Apps/Gluu/GluuCommitDialog.tsx
  • admin-ui/app/routes/Apps/Gluu/GluuScriptErrorModal.tsx
  • admin-ui/app/routes/Apps/Gluu/GluuSessionTimeout.tsx
  • admin-ui/app/routes/Apps/Gluu/LanguageMenu.tsx
  • admin-ui/app/routes/Apps/Gluu/ThemeDropdown.tsx
  • admin-ui/app/routes/Apps/Profile/hooks/useProfileDetails.ts
  • admin-ui/app/routes/License/hooks/useLicenseDetails.ts
  • admin-ui/app/routes/Pages/ByeBye.tsx
  • admin-ui/app/routes/index.tsx
  • admin-ui/app/utils/AppAuthProvider.tsx
  • admin-ui/app/utils/apiErrorMessage.ts
  • admin-ui/app/utils/logger.ts
  • admin-ui/app/utils/pagingUtils.ts
  • admin-ui/app/utils/triggerWebhookForFeature.ts
  • admin-ui/app/utils/types/LoggerTypes.ts
  • admin-ui/app/utils/types/index.ts
  • admin-ui/orval/__tests__/interceptors.test.ts
  • admin-ui/orval/interceptors.ts
  • admin-ui/plugins/PluginMenuResolver.ts
  • admin-ui/plugins/internal/loadPluginMetadata.ts

Comment thread admin-ui/app/routes/Apps/Gluu/GluuAppSidebar.tsx
Comment thread admin-ui/app/routes/Apps/Gluu/GluuSessionTimeout.tsx Outdated
Comment thread admin-ui/app/routes/License/hooks/useLicenseDetails.ts
Comment thread admin-ui/app/routes/License/hooks/useLicenseDetails.ts Outdated
Signed-off-by: faisalsiddique4400 <faisalsiddique10886@gmail.com>
@sonarqubecloud

sonarqubecloud Bot commented Jun 8, 2026

Copy link
Copy Markdown

@duttarnab duttarnab left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should follow the standard approach for displaying logs. We have the following log levels: TRACE, DEBUG, INFO, WARN, ERROR, and FATAL. Users should be able to configure the GUI log level from the UI, similar to how they can configure the theme or locale. The Admin UI should then display logs in the browser console according to the configured log level.

Dividing the display mode into dev, prod, and both will not work well when troubleshooting production issues, as there may be a need to view dev-level logs during the investigation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-admin-ui Component affected by issue or PR kind-feature Issue or PR is a new feature request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(admin-ui): Migrate Home/Core module to unified logger

3 participants