Refactor Logger methods for clarity and const correctness#47
Refactor Logger methods for clarity and const correctness#47kimkulling merged 4 commits intomainfrom
Conversation
|
Warning Rate limit exceeded@kimkulling has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 21 minutes and 11 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (2)
WalkthroughTwo modifications to Logger.cpp: a conditional logic refactoring in Logger::print that consolidates two separate checks into a single combined condition, and a signature change to Logger::unregisterLogStream adding const-correctness by accepting const AbstractLogStream* instead of AbstractLogStream*. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
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. Comment |
Updated comments and parameter types in Logger.h for clarity.
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
code/Common/Logger.cpp(2 hunks)
🔇 Additional comments (1)
code/Common/Logger.cpp (1)
192-195: LGTM! Clean control flow simplification.Consolidating the size check and character checks into a single condition improves readability while preserving the original behavior. The refactored structure now mirrors the pattern at line 166.
| } | ||
|
|
||
| void Logger::unregisterLogStream(AbstractLogStream *logStream) { | ||
| void Logger::unregisterLogStream(const AbstractLogStream *logStream) { |
There was a problem hiding this comment.
🧩 Analysis chain
Verify header file signature matches.
The const-correctness improvement is good, making the function more permissive by accepting both const and non-const pointers. However, since this is a public API change, ensure the header file declaration has been updated to match this signature.
Run the following script to verify the header file contains the matching signature:
🏁 Script executed:
#!/bin/bash
# Description: Verify that Logger.h declares unregisterLogStream with const parameter
# Search for the function declaration in header files
rg -n "unregisterLogStream" --type=h -C 2Length of output: 372
Update header file signature to match implementation.
The header file at include/cppcore/Common/Logger.h:169 still declares the old signature without const, but the implementation adds const to the parameter. This signature mismatch will cause compilation errors.
Update line 169 from:
void unregisterLogStream(AbstractLogStream *pLogStream);
to:
void unregisterLogStream(const AbstractLogStream *pLogStream);
Also note the parameter name differs between header (pLogStream) and implementation (logStream)—consider standardizing for consistency.
🤖 Prompt for AI Agents
In include/cppcore/Common/Logger.h around line 169, the declaration still uses a
non-const parameter but the implementation in code/Common/Logger.cpp at line 233
uses const; update the header declaration to match the implementation by
changing the parameter type to const AbstractLogStream * and, for consistency,
align the parameter name with the implementation (e.g., use logStream or
pLogStream consistently) so the signature and names match across header and
source.
|



Summary by CodeRabbit