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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error logging and reporting #3920

Draft
wants to merge 1 commit into
base: 1.4.4
Choose a base branch
from

Conversation

JavidPack
Copy link
Collaborator

Users have a hard time investigating errors to fix issues with their mod selections. Currently error messages hint to open up client.log, but only if the user is actively modding. Novice modders not using a debugger would see that hint, but would not know how to do that without reading the FAQ here on our wiki. Normal users would only see errors reported if they are thrown during mod loading.

This PR aims to improve error reporting to further facilitate users self-diagnosing issues.

Repeated Errors

Current behavior is to report an error only once. This behavior hides the severity of some issues. Code has been added to track how many times a specific error has been encountered. Errors will be logged at 1, 10, and 100 repetitions, with 10 and 100 reports escalating to Error status and having an accompanying "The following exception has been repeated 100 times:" message.
image

ModExceptionDiagnostics window

As the UIModNetDiagnostics window suggests the "health" of a mod's networking usage, a UIModExceptionDiagnostics window would suggest the "health" of a mod's code. User can press F8 a few times to arrive at this menu, allowing them to quickly appraise the health of a mod. This window will show errors accumulating in real time, making it even better than using the tail command or constantly reloading the client.log file. This is especially true for errors that will be omitted from client.log because they are repeats. Users can open the window and repeat a gameplay action that seems to be buggy or laggy. They will be able to immediately see the error count for the buggy mod increasing, suggesting which mod is causing the unexpected behavior.

TODO: This window can be augmented with additional counters for "ignored" exceptions and for displaying the most recent exception or a listing of all exceptions, whatever is deemed useful.

NVIDIA_Share_2023-11-06_14-48-34.mp4

Open up logs folder directly (TODO)

Users don't know hot to get to client.log. We should provide a way to quickly open the logs folder or the specific log file.

One option is to for clicking on the "see client.log for full trace" message to open client.log directly.
image

Another option is adding a 馃摐 button on the main menu to open the logs folder.
image

Ignored Exceptions (TODO)

We allow modders to silence specific exceptions via Logging.IgnoreExceptionSource/IgnoreExceptionContents. This is useful for handling known exceptions, but it could be misused by modders, preventing effective troubleshooting by users.

At the very least, it would be useful to log these additions: "System.InvalidCastException added to exception ignore list by ExampleMod". It might be useful to provide a "verbose" mode via a command line parameter that would ignore all of these filters, just in case a specific bug is not being reported properly in logs. Another thought is to track these exceptions and report them in the ModExceptionDiagnostics window, explained in another section.

Console

The console is not visible for normal client gameplay after launching, but it would be visible when doing host and play once #2705 is fixed. It is visible when debugging tModLoader itself as well. The colors can be adjusted.

Colors have been added for info/debug/warn/error:
image

@Chicken-Bones
Copy link
Member

I would like to see this complimented by several user stories to better understand the situations, and evaluate the effectiveness of the intended solution. Who is the target audience for these improvements? Will these changes cause confusion or problems for players with negligible modding experience?

Clearly good ideas:

  • Click on a first chance exception during main menu to see the log
  • Logging errors repeatedly every order of magnitude

Probably helpful:

  • Console text coloring.
    • Recommend keeping DEBUG as white, because we don't have any consistent rule dividing DEBUG and INFO
  • Showing silently caught exceptions to regular users
    • Need to direct them to logs and troubleshooting resources.
    • Consider a way to show them in the main menu as well?

Probably not useful:

  • Logging ignored exception filters, or a way to log all silent exceptions, even ignored ones.
    • This information would be difficult to interpret, and in almost all situations a debugger or profiler would be needed to correctly determine the issue.
  • Logs icon on main menu
    • I don't think anyone will notice it. A button in the mods menu could be useful though.
  • The ModExceptionDiagnosticsUI
    • The main issue here is that it's impossible to correctly attribute an exception to a mod, and misattribution may cause more harm than good. The only thing a user can do with the information in that window is to open the logs, or complain to a mod author.

It seems like this PR is aimed at silently caught exceptions during gameplay. I think we should start by simply surfacing errors to users, and getting reports with logs. Then we can continue with more guided troubleshooting, like identifying all mods and IL hooks involved in a stack trace.

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.

None yet

2 participants