Skip to content

fix(logger): remove spurious debug prefix from cmd arrays in console#115

Merged
water-sucks merged 1 commit intonix-community:mainfrom
water-sucks:fix-logs
Oct 23, 2025
Merged

fix(logger): remove spurious debug prefix from cmd arrays in console#115
water-sucks merged 1 commit intonix-community:mainfrom
water-sucks:fix-logs

Conversation

@water-sucks
Copy link
Copy Markdown
Collaborator

@water-sucks water-sucks commented Oct 23, 2025

The ConsoleLogger used the debug writer for writing the output, which appended a debug: prefix to each array, which makes it look pretty dirty.

This removes that and uses a separate writer for it.

Summary by CodeRabbit

  • Chores
    • Improved internal logging infrastructure for command output formatting and display consistency. Enhanced console logger to better handle command composition and maintain consistent styling across output.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Oct 23, 2025

Walkthrough

Internal refactoring of the console logger to separate command output routing. Adds a dedicated cmd logger field to ConsoleLogger, initializes it with a "$-prefixed prompt in NewConsoleLogger, routes CmdArray output through this logger instead of debug, and maintains the cmd prefix in RefreshColorPrefixes.

Changes

Cohort / File(s) Summary
Console Logger Command Output
internal/logger/console.go
Added cmd field (*log.Logger) to ConsoleLogger struct; initialized in NewConsoleLogger with "$" prefix; updated CmdArray to route command messages to cmd logger instead of debug logger; RefreshColorPrefixes now updates cmd prefix alongside other color prefixes

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

The changes are localized to a single file with straightforward logic: one new field, simple initialization, and method behavior updates that redirect output to a dedicated logger. The refactoring is consistent and does not introduce complex interdependencies.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "fix(logger): remove spurious debug prefix from cmd arrays in console" is directly related to the main change in the changeset. The title accurately describes the core objective: eliminating an unwanted debug prefix that was being appended to command array output. The changes—introducing a separate cmd logger field and modifying the CmdArray method to use this new logger instead of the debug logger—directly support this goal. The title is concise, specific, and follows conventional commit formatting, making it clear to someone reviewing the history what problem is being addressed.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
internal/logger/console.go (1)

129-130: Consider removing redundant color application for consistency.

The blue.Sprintf on line 129 applies blue coloring to the command text, but the cmd logger already has a blue prefix. This is inconsistent with other log methods (Debug, Info, Warn, Error) which don't apply additional coloring beyond their prefixes.

Apply this diff for consistency with other log methods:

-	msg := blue.Sprintf("%v", utils.EscapeAndJoinArgs(argv))
-	l.cmd.Printf("%v\n", msg)
+	l.cmd.Println(utils.EscapeAndJoinArgs(argv))

This maintains the blue "$ " prefix while keeping the command text uncolored, consistent with how other log levels work.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4775307 and 159d296.

📒 Files selected for processing (1)
  • internal/logger/console.go (4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
internal/logger/console.go (2)
internal/logger/logger.go (1)
  • Logger (12-27)
internal/utils/utils.go (1)
  • EscapeAndJoinArgs (27-41)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build/Test
🔇 Additional comments (3)
internal/logger/console.go (3)

20-20: LGTM! Good separation of concerns.

Adding a dedicated cmd logger field properly separates command output from debug output, removing the spurious "debug:" prefix issue.


35-35: LGTM! Proper initialization.

The cmd logger is correctly initialized with a blue "$ " prefix, consistent with the shell prompt convention.


155-155: LGTM! Proper prefix refresh.

The cmd logger prefix is correctly updated in RefreshColorPrefixes, ensuring the "$ " prompt maintains consistent coloring when colors are toggled on or off.

@water-sucks water-sucks merged commit 7e504f6 into nix-community:main Oct 23, 2025
2 checks passed
@water-sucks water-sucks deleted the fix-logs branch October 23, 2025 06:50
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