Skip to content

GH-120 Add debug mode #120

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

Merged
merged 3 commits into from
Mar 17, 2025
Merged

GH-120 Add debug mode #120

merged 3 commits into from
Mar 17, 2025

Conversation

Jakubk15
Copy link
Member

image

Closes #95

@Jakubk15 Jakubk15 added the 🆕 feature New feature or request label Mar 15, 2025
Copy link
Contributor

coderabbitai bot commented Mar 15, 2025

Walkthrough

This pull request introduces a debug mode into the plugin by adding a new boolean configuration flag and integrating conditional logging. A public static logger, DEBUG_LOGGER, is added to the main class and is set based on the debug configuration during the plugin’s enable phase. The configuration now includes a boolean field debug (defaulting to false) within the settings. In addition, several methods in the database repository wrapper class have been updated to log their operations using this new debug logger, providing more detailed internal logging when debug mode is active.

Assessment against linked issues

Objective Addressed Explanation
Enable debug mode configuration and debug logging (#95)
Implement parcel locker click preview and in-game error reporting (#95) No changes implement a UI preview or direct error messages to players.

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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 generate docstrings to generate docstrings for this 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.

@Jakubk15 Jakubk15 changed the title Add debug mode GH-120 Add debug mode Mar 15, 2025
Copy link
Contributor

@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)
src/main/java/com/eternalcode/parcellockers/database/wrapper/AbstractRepositoryOrmLite.java (1)

73-75: Consider adding logging to selectAll method for consistency

All other methods have logging added, but selectAll still uses the direct reference. Consider adding logging here too.

 protected <T> CompletableFuture<List<T>> selectAll(Class<T> type) {
-    return this.action(type, Dao::queryForAll);
+    return this.action(type, dao -> {
+        ParcelLockers.DEBUG_LOGGER.info("Selecting all entities of type: {}", type.getSimpleName());
+        return dao.queryForAll();
+    });
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 249f759 and 933853b.

📒 Files selected for processing (4)
  • src/main/java/com/eternalcode/parcellockers/ParcelLockers.java (3 hunks)
  • src/main/java/com/eternalcode/parcellockers/configuration/implementation/PluginConfiguration.java (1 hunks)
  • src/main/java/com/eternalcode/parcellockers/database/wrapper/AbstractRepositoryOrmLite.java (2 hunks)
  • src/main/java/com/eternalcode/parcellockers/util/NullLogger.java (1 hunks)
🔇 Additional comments (13)
src/main/java/com/eternalcode/parcellockers/configuration/implementation/PluginConfiguration.java (1)

42-44: Good addition of debug mode setting

The new debug flag is well-documented with a clear description. Nice job setting the default to false to avoid flooding the console unnecessarily.

src/main/java/com/eternalcode/parcellockers/util/NullLogger.java (1)

1-312: Good implementation of null logger pattern

The NullLogger class properly implements all Logger interface methods with no-op implementations. This is a clean approach to handle disabled debug logging without conditional checks throughout the code.

src/main/java/com/eternalcode/parcellockers/database/wrapper/AbstractRepositoryOrmLite.java (8)

4-4: Appropriate import added

The import for ParcelLockers is needed to access the DEBUG_LOGGER.


25-28: Good logging implementation for save method

The logging statement provides useful context before performing the database operation.


32-35: Good logging implementation for saveIfNotExist method

Clear logging message with context about the operation and entity.


39-42: Good logging implementation for select method

The logging provides useful information about the ID being selected.


46-49: Good logging implementation for selectSafe method

Appropriate logging with indication that it's in safe mode.


53-56: Good logging implementation for delete method

Clear logging of the entity being deleted.


60-63: Good logging implementation for deleteAll method

Simple but informative logging message for bulk deletion.


67-70: Good logging implementation for deleteById method

Appropriate logging with the ID being deleted.

src/main/java/com/eternalcode/parcellockers/ParcelLockers.java (3)

40-40: Appropriate import added

Good addition of the NullLogger import to support the debug mode feature.


73-73: Good addition of static logger field

The DEBUG_LOGGER is properly declared as public static to be accessible throughout the application.


113-117: Well-implemented conditional logger initialization

The logger is properly initialized based on the debug setting. Using a NullLogger when debug is disabled is an efficient approach.

coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 15, 2025
Copy link
Contributor

@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)
src/main/java/com/eternalcode/parcellockers/database/wrapper/AbstractRepositoryOrmLite.java (1)

74-74: Added logging in selectAll method

Nice addition, but note this logging is placed outside the action lambda unlike other methods. This works fine but is slightly inconsistent with the pattern used elsewhere.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 933853b and 91443ff.

📒 Files selected for processing (1)
  • src/main/java/com/eternalcode/parcellockers/database/wrapper/AbstractRepositoryOrmLite.java (2 hunks)
🔇 Additional comments (8)
src/main/java/com/eternalcode/parcellockers/database/wrapper/AbstractRepositoryOrmLite.java (8)

4-4: Import added for debug logging

The import for ParcelLockers class is added to access the DEBUG_LOGGER.


25-28: Added logging in save method

Simple logging added when saving entities to help with debugging database operations.


32-35: Added logging in saveIfNotExist method

Helpful log statement with clear context about the save operation mode.


39-42: Added logging in select method

Basic logging to track entity selection operations by ID.


46-49: Added logging in selectSafe method

Good logging that clarifies this is using the safe mode (returning Optional).


53-56: Added logging in delete method

Simple tracking of entity deletion operations.


60-63: Added logging in deleteAll method

Good use of type.getSimpleName() to show which entity type is being deleted.


67-70: Added logging in deleteById method

Simple tracking for deletion by ID operations.

coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 16, 2025
imDMK
imDMK previously approved these changes Mar 16, 2025
@Rollczi Rollczi dismissed stale reviews from imDMK and coderabbitai[bot] via 4661315 March 16, 2025 20:52
Copy link
Contributor

@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 (2)
src/main/java/com/eternalcode/parcellockers/ParcelLockers.java (2)

73-73: Added static debug logger

The logger is properly initialized with a no-operation logger. Consider adding a brief comment to explain its purpose for easier understanding by other developers.

-    public static org.slf4j.Logger DEBUG_LOGGER = NOPLogger.NOP_LOGGER;
+    // Logger for debug mode, only logs when debug is enabled in config
+    public static org.slf4j.Logger DEBUG_LOGGER = NOPLogger.NOP_LOGGER;

113-115: Added debug mode configuration

Good implementation of the debug mode toggle. The logger gets properly initialized when debug is enabled in the configuration.

     if (config.settings.debug) {
-        DEBUG_LOGGER = org.slf4j.LoggerFactory.getLogger("ParcelLockers] [DEBUG");
+        DEBUG_LOGGER = org.slf4j.LoggerFactory.getLogger("ParcelLockers-DEBUG");
     }

The logger name format is a bit unusual. Consider using a more standard naming format.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 91443ff and 4661315.

📒 Files selected for processing (1)
  • src/main/java/com/eternalcode/parcellockers/ParcelLockers.java (2 hunks)
🔇 Additional comments (1)
src/main/java/com/eternalcode/parcellockers/ParcelLockers.java (1)

69-69: Added import for NOPLogger

Good addition of the import needed for the new debug logger functionality.

@Jakubk15 Jakubk15 merged commit 5feeea1 into master Mar 17, 2025
2 checks passed
@Jakubk15 Jakubk15 deleted the debug-mode branch March 17, 2025 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🆕 feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add debug mode
4 participants