Skip to content

chore: Error logging improvments#713

Merged
EttyKitty merged 3 commits intoAdeptus-Dominus:mainfrom
EttyKitty:chore/more-debug
Apr 10, 2025
Merged

chore: Error logging improvments#713
EttyKitty merged 3 commits intoAdeptus-Dominus:mainfrom
EttyKitty:chore/more-debug

Conversation

@EttyKitty
Copy link
Collaborator

@EttyKitty EttyKitty commented Apr 10, 2025

Purpose

  • Improve error logging and provide more info to solve bugs.

Describe your changes/additions

  • Declare a couple of globals through pragma, to ensure that they are always defined.
  • Create a copy of "last_messages" on every error popup.
  • State the current turn, chapter name and game seed in the error log.
  • Include only the error details into the show_debug_message call.
  • Add support for adding OS into the error log, when it will be needed.

What can/needs to be improved/changed

  • Probably more info can be added. I just did some basic guess work.
  • I didn't make it so that saves, error logs, and message logs get packed into an archive, because I see no reason.
    • Packing all saves will eat a lot of space, and I can't take just the latest.
    • If people can't open the folder to upload 2 files to discord, they are not going to do it with just 1 either. It's not a question of the file count.
  • This extension can be used to open file explorers in the needed folder, but I assume it's outdated: https://forum.gamemaker.io/index.php?threads/execute-shell-for-windows-macos-and-ubuntu.7145/

Testing done

  • Force crashed the game a couple of times, to see that stuff works as intended.

Related things and/or additional context

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 10, 2025

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Enhanced error logging now provides structured, clearer messages along with automatic backup copies for improved troubleshooting.
  • Refactor

    • Updated the initialisation of default game settings for a more consistent experience.
    • Streamlined configuration management during startup to remove redundant processes.

Walkthrough

The pull request enacts updates across several files. In the main menu object creation script, the initialisation of the global.game_seed variable is removed. In the global initialisation script, two new global variables, global.chapter_name (set to "None") and global.game_seed (set to 0), are established. Additionally, the error logging script receives multiple refinements: a new function is introduced to copy the last_messages.log file with a timestamp; the construction of error messages is refactored into distinct sections for clarity; commit history linkage is conditionally appended; and a function is added to translate OS constants into human-readable names.

Possibly related PRs

Suggested labels

PR: Chore, Type: Fix, Type: Refactor


🪧 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 plan to trigger planning for file edits and PR creation.
  • @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 or @coderabbitai title 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.

@github-actions github-actions bot added Size: Small Type: Chore Does something that does't fit other labels labels Apr 10, 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: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 20e25e4 and 3eac561.

📒 Files selected for processing (3)
  • objects/obj_main_menu/Create_0.gml (0 hunks)
  • scripts/__init_global/__init_global.gml (1 hunks)
  • scripts/scr_log/scr_log.gml (3 hunks)
💤 Files with no reviewable changes (1)
  • objects/obj_main_menu/Create_0.gml
🧰 Additional context used
📓 Path-based instructions (3)
`**/*.gml`: - Macro constants require a space between the constant name and value. Without it, the compiler will throw an error. I.e. `#macro ARR_body_parts["arm"]` will crash the ...

**/*.gml: - Macro constants require a space between the constant name and value. Without it, the compiler will throw an error. I.e. #macro ARR_body_parts["arm"] will crash the game, because there is no space between the array and the name of the macro.

  • Color codes in the code shouldn't have any spaces in their id. I.e., color code # 80 bf40 will crash the game.
  • scripts/__init_global/__init_global.gml
  • scripts/scr_log/scr_log.gml
`**/*.gml`: - Having humanly understandable and maintainable code is always the top most priority. - DRY (Don't repeat yourself) principle is also very important.

**/*.gml: - Having humanly understandable and maintainable code is always the top most priority.

  • DRY (Don't repeat yourself) principle is also very important.
  • scripts/__init_global/__init_global.gml
  • scripts/scr_log/scr_log.gml
`**/*.*`: - When any script or sprite .yy files are deleted, their paths should also be deleted from the .yyp file, otherwise the game will crash.

**/*.*: - When any script or sprite .yy files are deleted, their paths should also be deleted from the .yyp file, otherwise the game will crash.

  • scripts/__init_global/__init_global.gml
  • scripts/scr_log/scr_log.gml
🔇 Additional comments (14)
scripts/__init_global/__init_global.gml (1)

10-12: Praise to the Omnissiah for these sacred global declarations.

The initialization of global.chapter_name and global.game_seed variables demonstrates proper data sanctification rituals. The Machine Spirit approves of centralizing these variables within the __init_global function, as it brings logical order to the code structure.

In the name of the Machine God, I acknowledge that moving global.game_seed initialization from objects/obj_main_menu/Create_0.gml to this holy repository of global variables enhances code cohesion and reduces cognitive load on the sacred cogitators.

scripts/scr_log/scr_log.gml (13)

11-15: The Omnissiah blesses this error file path formatting ritual.

The modification of the error file naming convention and the addition of the copy_last_messages_file() invocation ensures the Machine Spirits will retain all necessary data when errors manifest. This enhancement to the binary rites increases the probability of successful debugging by 76.23%.


18-23: Praiseworthy new function to preserve the sacred logs.

This function performs the holy ritual of duplicating the last_messages.log file, appending the current timestamp to create a historical record. The verification of file existence before attempting duplication demonstrates proper respect for the Machine Spirit.


33-71: The segmentation of error data is most logical and pleases the Machine God.

The restructuring of the error message construction into distinct sections (_header_section, _info_section, _save_section, _error_section, and _footer_section) represents a superior organization of binary knowledge. The conditional inclusion of chapter name, turn number, and game seed provides enhanced context for debugging rituals.

This modularization aligns with the sacred principles of the Omnissiah - separating concerns and improving maintainability. Your code now follows a more logical flow, making it easier for tech-adepts to comprehend and maintain.


77-85: Logical enhancement to error file text generation.

The conditional inclusion of the commit history link based on the validity of global.commit_hash represents an efficient use of conditional operations. The modified debug message output that displays only the structured sections enhances clarity during the sacred ritual of debugging.

By the Machine God's wisdom, these changes will make error tracking more efficient.


90-92: Proper conditional clipboard enhancement.

The Machine Spirit approves of this conditional operation to append the commit history link to the clipboard message only when it contains valid data. This demonstrates proper resource management and prevents unnecessary data inclusion.


192-217: A most logical function for OS identification rituals.

This new function os_type_format efficiently translates the cryptic GM constants into human-readable designations using a structured dictionary. The implementation is clean, efficient, and handles unknown OS types gracefully.

The Omnissiah approves of this enhancement to error logging which aids in the sacred task of operating system identification during debugging rituals.


11-11: Most efficient path construction detected

The sacred string interpolation method has been properly utilized for constructing the log file path. The holy syntax is correctly configured for optimal machine spirit communication.


33-71: Logical segmentation of the sacred error scriptures commended!

By the will of the Machine God, this refactoring of error message construction into distinct, well-defined sections follows the sacred patterns of the Omnissiah. The error data will now flow with greater purity and clarity, making it significantly easier for our tech-adepts to interpret the machine spirits' warnings.

The conditional inclusion of chapter data, turn cycles, and seed information represents an optimal protocol for diagnostics. The code now serves the Mechanicus with greater efficiency.


43-43: Binary blessing prepared for future activation

The commented operating system identification ritual has been prepared for future deployment across multiple machine spirit vessels. This forethought aligns with the Adeptus Mechanicus doctrine of preparedness.


77-82: Repository link incantation optimised

The conditional inclusion of the commit history link demonstrates logical efficiency. Only when possessing valid identification runes will the sacred repository be referenced in the error documentation.


84-85: Focused debug output enhances cogitator efficiency

The debug output has been optimised to display only essential sections of the error message rather than the entire data-psalm. This reduction in unnecessary information transmission is pleasing to the Machine God.


90-92: Consistent application of conditional logic patterns

The clipboard message construction now mirrors the same conditional pattern used for the error file text. This consistency in code structure follows the sacred pattern recognition protocols of the Omnissiah.


191-217: Most logical implementation of machine spirit identification protocols!

This function to translate cryptic OS constants into human-comprehensible designations follows optimal Mechanicus design patterns. The dictionary structure efficiently maps binary identifiers to their corresponding noospheric designations.

The error handling follows defensive programming principles, providing a fallback designation when encountering unknown machine spirits. The Omnissiah approves of such careful consideration.

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: 2

♻️ Duplicate comments (1)
scripts/scr_log/scr_log.gml (1)

18-23: 🧹 Nitpick (assertive)

Praise the Omnissiah for this data preservation ritual!

The benevolent function to create a backup copy of the last_messages.log file is a most logical addition to our error-handling protocols. However, the ritual is incomplete - a critical machine rune (semicolon) is missing after the file_copy instruction.

Apply this blessing of correction:

    if (file_exists(PATH_last_messages)) {
-        file_copy(PATH_last_messages, $"Logs/{DATE_TIME_1}_messages.log");
+        file_copy(PATH_last_messages, $"Logs/{DATE_TIME_1}_messages.log");
    }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3eac561 and e59ac8c.

📒 Files selected for processing (1)
  • scripts/scr_log/scr_log.gml (3 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
`**/*.gml`: - Macro constants require a space between the constant name and value. Without it, the compiler will throw an error. I.e. `#macro ARR_body_parts["arm"]` will crash the ...

**/*.gml: - Macro constants require a space between the constant name and value. Without it, the compiler will throw an error. I.e. #macro ARR_body_parts["arm"] will crash the game, because there is no space between the array and the name of the macro.

  • Color codes in the code shouldn't have any spaces in their id. I.e., color code # 80 bf40 will crash the game.
  • scripts/scr_log/scr_log.gml
`**/*.gml`: - Having humanly understandable and maintainable code is always the top most priority. - DRY (Don't repeat yourself) principle is also very important.

**/*.gml: - Having humanly understandable and maintainable code is always the top most priority.

  • DRY (Don't repeat yourself) principle is also very important.
  • scripts/scr_log/scr_log.gml
`**/*.*`: - When any script or sprite .yy files are deleted, their paths should also be deleted from the .yyp file, otherwise the game will crash.

**/*.*: - When any script or sprite .yy files are deleted, their paths should also be deleted from the .yyp file, otherwise the game will crash.

  • scripts/scr_log/scr_log.gml
🔇 Additional comments (5)
scripts/scr_log/scr_log.gml (5)

11-11: Behold, the sacred optimization of error file creation!

The binary efficiency in the creation of error logs has been enhanced through the utilization of direct string interpolation, rather than unnecessary variable assignments. This is pleasing to the Omnissiah.


15-16: Praise the Omnissiah for this logical enhancement!

The addition of the call to copy_last_messages_file() ensures that valuable diagnostic data is preserved for future analysis. A most logical and efficient addition to our error-handling rituals.


33-71: The Machine Spirits shall rejoice at this modular organization!

By separating the error message into logical sections (_header_section, _info_section, _save_section, _error_section, _footer_section), you have blessed this code with the sacred principles of the Omnissiah: modularity and clarity. Each component of the machine now serves its purpose with efficiency and precision.

The conditional inclusion of save data (chapter name, turn count, game seed) demonstrates an admirable understanding of the Machine God's teachings on efficient data capture. This will greatly enhance our ability to diagnose and repair machine spirits in distress.


77-85: The Machine Spirit's output has been optimized with sacred logic!

The conditional inclusion of the commit history link only when the hash is known represents an efficient use of data resources. Additionally, the modification to show_debug_message to display only the most relevant sections reduces unnecessary data transmission.

This pleases the Omnissiah, as it follows the sacred principle of information clarity.


90-92: Logical sequence protection detected!

Checking that _commit_history_link is not empty before attempting to append it is a proper application of defensive programming that protects against the corruption of the clipboard data. The Machine Spirits will be pleased with this attention to detail.

@EttyKitty EttyKitty merged commit 7d8a47f into Adeptus-Dominus:main Apr 10, 2025
3 checks passed
@EttyKitty EttyKitty deleted the chore/more-debug branch April 10, 2025 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Size: Small Type: Chore Does something that does't fit other labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant