Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logger: remove not needed semicolons #247

Merged
merged 1 commit into from
Oct 14, 2024
Merged

Conversation

kimkulling
Copy link
Owner

@kimkulling kimkulling commented Oct 14, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a method to unregister log streams, enhancing logging capabilities.
  • Bug Fixes

    • Improved error handling and syntax in the Python interface and camera component methods.
  • Refactor

    • Cleaned up code formatting, including the removal of unnecessary blank lines and standardization of macro definitions.

Copy link

coderabbitai bot commented Oct 14, 2024

Walkthrough

The changes in this pull request focus on improving error handling and code formatting across several files. In PythonInterface.cpp, error logging statements were corrected with semicolons, and the gActiceProject variable was initialized and checked for nullity. The CameraComponent.cpp file saw a similar update with a semicolon added to a logging statement. Lastly, Logger.h introduced a new method to unregister log streams and standardized macro definitions. Overall, the modifications enhance code clarity and correctness without altering core functionalities.

Changes

File Change Summary
src/Editor/src/Scripting/PythonInterface.cpp Added semicolons to error logging statements; initialized gActiceProject variable; updated method signatures for create, destroy, addPath, and runScript. Removed unnecessary blank lines.
src/Engine/App/CameraComponent.cpp Added a semicolon to the logging statement in setCameraModel method.
src/Engine/Common/Logger.h Added unregisterLogStream method; removed semicolons from macro definitions for logging functions.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PythonInterface
    participant Logger

    User->>PythonInterface: create()
    PythonInterface->>Logger: Log creation attempt
    Logger-->>PythonInterface: Log success or error
    PythonInterface->>User: Return creation result
Loading

🐇 In the code we hop and play,
🐇 Fixing errors day by day.
🐇 Semicolons here, a method new,
🐇 Cleaner logs and paths to pursue.
🐇 Hooray for changes, let’s rejoice,
🐇 In our code, we’ve made a choice!
🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@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: 1

🧹 Outside diff range and nitpick comments (2)
src/Editor/src/Scripting/PythonInterface.cpp (1)

222-222: Approve semicolon additions and suggest minor improvement.

The addition of semicolons to the osre_error calls is correct and necessary. These changes ensure proper syntax and prevent potential compilation errors.

Consider updating the error message in PythonInterface::destroy:

-        osre_error(Tag, "Error while destoy, Python interface is not created.");
+        osre_error(Tag, "Error while destroy, Python interface is not created.");

This corrects the typo in "destoy" to "destroy".

Also applies to: 225-225, 245-245, 250-250

src/Engine/Common/Logger.h (1)

217-249: Approved: Consistent improvement across all logging macros

The removal of semicolons from all logging macro definitions (osre_debug, osre_info, osre_warn, osre_error, and osre_fatal) is consistent and improves the flexibility of the entire logging system. This change allows these macros to be used more robustly in various contexts.

Consider using a single macro definition for all log levels to improve maintainability. For example:

#define OSRE_LOG(level, domain, msg) ::OSRE::Common::level##Print(domain, __FILE__, __LINE__, msg)

// Usage:
OSRE_LOG(trace, domain, msg);
OSRE_LOG(debug, domain, msg);
// ... and so on for other log levels

This approach would centralize the logging logic and make it easier to maintain and modify in the future.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 59a4f27 and 860ec43.

📒 Files selected for processing (3)
  • src/Editor/src/Scripting/PythonInterface.cpp (7 hunks)
  • src/Engine/App/CameraComponent.cpp (1 hunks)
  • src/Engine/Common/Logger.h (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/Engine/App/CameraComponent.cpp
🧰 Additional context used
🔇 Additional comments (7)
src/Editor/src/Scripting/PythonInterface.cpp (4)

70-70: Approve semicolon addition.

The addition of the semicolon after new Project() is correct and necessary. This change improves the code's syntax and prevents potential compilation errors.


83-83: Approve blank line addition.

The addition of a blank line improves code readability by separating logical blocks of code. This change adheres to good coding practices and makes the function structure clearer.


196-196: Approve semicolon additions to error logging calls.

The addition of semicolons to the osre_error calls is correct and necessary. These changes ensure proper syntax and prevent potential compilation errors.

Also applies to: 207-207, 211-211


Line range hint 1-259: Summary of changes and recommendations.

The changes in this file primarily focus on improving code correctness by adding necessary semicolons to error logging calls and initializing a global pointer. These modifications prevent potential compilation errors and adhere to good coding practices.

Key points:

  1. Semicolons were added to osre_error calls throughout the file.
  2. A global pointer gActiceProject was initialized to nullptr.
  3. A blank line was added in the osre_project_load function to improve readability.

Recommendations:

  1. Fix the typo in the global pointer name from gActiceProject to gActiveProject.
  2. Correct the typo in the error message in PythonInterface::destroy from "destoy" to "destroy".

Overall, these changes improve the code quality and maintainability.

src/Engine/Common/Logger.h (3)

159-162: LGTM: Good addition of unregisterLogStream method

The new unregisterLogStream method is a valuable addition to the Logger class. It provides symmetry with the existing registerLogStream method and allows for more flexible management of log streams. The method signature is consistent with the class's coding style.


209-209: Approved: Improved macro definition

Removing the semicolon from the osre_trace macro definition is a good practice. This change allows the macro to be used more flexibly in different contexts without introducing unexpected semicolons. It improves the overall robustness of the macro system.


Line range hint 1-249: Summary: Positive improvements to the logging system

The changes made to src/Engine/Common/Logger.h are well-implemented and improve the functionality and correctness of the logging system. Key improvements include:

  1. Addition of the unregisterLogStream method, providing better control over log streams.
  2. Removal of semicolons from macro definitions, improving their flexibility and robustness.

These changes enhance the usability and maintainability of the logging system. The suggestion to use a single macro for all log levels could further improve maintainability in the future.

Overall, these changes are approved and ready for merging.

@@ -49,7 +49,7 @@ typedef struct Osre_Project {
Stage *mStage;
Project *mProject;
} Osre_Project;

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix typo in variable name and approve initialization.

The variable name gActiceProject appears to have a typo. It should be gActiveProject. However, initializing the global pointer to nullptr is a good practice.

Please apply the following change:

-Osre_Project *gActiceProject = nullptr;
+Osre_Project *gActiveProject = nullptr;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Osre_Project *gActiveProject = nullptr;

Copy link

sonarcloud bot commented Oct 14, 2024

@kimkulling kimkulling merged commit 3c643ba into master Oct 14, 2024
4 checks passed
@kimkulling kimkulling deleted the bugfix/fix_log_macros branch October 14, 2024 09:22
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.

2 participants