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

Enhanced Error Logging with Node Path (Instance) Information #8345

Open
Ryan-000 opened this issue Nov 3, 2023 · 1 comment
Open

Enhanced Error Logging with Node Path (Instance) Information #8345

Ryan-000 opened this issue Nov 3, 2023 · 1 comment

Comments

@Ryan-000
Copy link

Ryan-000 commented Nov 3, 2023

Describe the project you are working on

A 3D Multiplayer Hero Shooter, although this feature applies to all other projects I've seen.

Describe the problem or limitation you are having in your project

During the development process, I frequently face errors related to nodes, but without any clear indication of which specific node(s) they are associated with.

The bigger and more complicated the game gets, the harder and more painful it becomes to resolve these engine errors. When an error pops up, all the engine tells me is that a check failed at in some C++ file. But, which at which instance? I'm left scratching my head and burning time just tracking down the root cause.

image

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Enhancement: Incorporate node path details (instance details) into the error logs.

This will significantly reduce debugging time by pointing out the exact origin of the issue.

It also will improve clarity in larger projects. As time goes on, more engine errors inevitably pop up in the log. However, because there's a lack of actionable information (specifically, what instance it happened on), developers tend to ignore them. Over time this neglect leads to a log that's cluttered with unhelpful, “random” errors.

Consequently, when real problems arise, spotting and fixing them within the overwhelming clutter becomes very difficult. If you ever attempt to tackle these engine errors to declutter the log, it's practically impossible to sift through them all, especially since the logs don't indicate their sources, leaving you with no idea where to start.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

As of now, an error log might look something like this:

instantiate_scene: Index (uint32_t)p_id = 0 is out of bounds (spawnable_scenes.size() = 0).
  <C++ Source>   modules/multiplayer/multiplayer_spawner.cpp:299 @ instantiate_scene()

With the proposed enhancement, the error log would be more informative:

instantiate_scene: Index (uint32_t)p_id = 0 is out of bounds (spawnable_scenes.size() = 0).
  <Affected Node> /root/Path/To/Whatever/Node
  <C++ Source>   modules/multiplayer/multiplayer_spawner.cpp:299 @ instantiate_scene()

For the actual implementation, I'd suggest introducing new macros named following the pattern ERR_INSTANCE_ExistingErrorMacroName. For example, if there's an existing macro named ERR_PRINT(string message), the new one could be ERR_INSTANCE_PRINT(object instance, string message). These macros would accept an instance object, and for nodes, they would display the node path.

Unfortunately, I'm not familiar with the specifics of macros and C++, so I cannot delve any deeper. Potentially, in future iterations (not in this particular proposal), support could be extended to work with other types, like resources.

For this to be effective, a good number of the currently used macros should be replaced with these new ones when it fits the context. As well as using these new instance macros instead the old ones when possible.

If this enhancement will not be used often, can it be worked around with a few lines of script?

It will be used often, and cannot be worked around.

Is there a reason why this should be core and not an add-on in the asset library?

Given that this proposal directly targets and enhances the core engine's logging functionality, it cannot be an add-on.

@Calinou
Copy link
Member

Calinou commented Nov 3, 2023

The issue with the proposed approach is that to get a good coverage of most error messages, you would need to pass node names deep in the function tree, leading to unnecessary overhead. There can easily be 4 levels of indirection between a node that does something and a low-level function that can print an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants