Custom TraceListener #1

Closed
opened 2024-03-21 10:54:12 +00:00 by aallard · 0 comments
aallard commented 2024-03-21 10:54:12 +00:00 (Migrated from git.frog-collective.com)
  • Improve the custom TraceListener to display all kind of log propertly (for example TraceError is not logged as a Godot error).

  • Configure a log category.

  • Add verbose level (change default depending on the build/editor)

  • Display /path/to/file:lineNumber instead of /path/to/file: line lineNumber (this allow to directly click on the path in vscode).

Assert

Current behavior:

Stack traces are displayed manually to follow these options:

  • hideInternalCalls: Don't display godot internal calls (C# and native). Keep source generator calls.
  • relativePath: display res://Sources/View/Player.cs:24 instead of /home/aallard/Repositories/the-guild/Project/Sources/View/Player.cs:24

Example with hideInternalCalls set to true:

Assertion failed.
    at View.Player._Process(Double delta) in /home/aallard/Repositories/the-guild/Project/Sources/View/Player.cs:24
    <internal calls>
    at View.Player.InvokeGodotClassMethod(godot_string_name& method, NativeVariantPtrArgs args, godot_variant& ret) in /home/aallard/Repositories/the-guild/Project/Godot.SourceGenerators/Godot.SourceGenerators.ScriptMethodsGenerator/View.Player_ScriptMethods.generated.cs:50
    <internal calls>

Exceptions

Current behavior:

Exception thrown: 'System.NullReferenceException' in TheGuild
ERROR: System.NullReferenceException: Object reference not set to an instance of an object.
   at View.Player._Process(Double delta) in /home/aallard/Repositories/the-guild/Project/Sources/View/Player.cs:line 25
   at Godot.Node.InvokeGodotClassMethod(godot_string_name& method, NativeVariantPtrArgs args, godot_variant& ret) in /root/godot/modules/mono/glue/GodotSharp/GodotSharp/Generated/GodotObjects/Node.cs:line 2111
   at Godot.Node3D.InvokeGodotClassMethod(godot_string_name& method, NativeVariantPtrArgs args, godot_variant& ret) in /root/godot/modules/mono/glue/GodotSharp/GodotSharp/Generated/GodotObjects/Node3D.cs:line 1035
   at View.Player.InvokeGodotClassMethod(godot_string_name& method, NativeVariantPtrArgs args, godot_variant& ret) in /home/aallard/Repositories/the-guild/Project/Godot.SourceGenerators/Godot.SourceGenerators.ScriptMethodsGenerator/View.Player_ScriptMethods.generated.cs:line 50
   at Godot.Bridge.CSharpInstanceBridge.Call(IntPtr godotObjectGCHandle, godot_string_name* method, godot_variant** args, Int32 argCount, godot_variant_call_error* refCallError, godot_variant* ret) in /root/godot/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/CSharpInstanceBridge.cs:line 24
   at: void Godot.NativeInterop.ExceptionUtils.LogException(System.Exception) (/root/godot/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/ExceptionUtils.cs:112)
Assertion failed.
    at View.Player._Process(Double delta) in /home/aallard/Repositories/the-guild/Project/Sources/View/Player.cs:24
    <internal calls>
    at View.Player.InvokeGodotClassMethod(godot_string_name& method, NativeVariantPtrArgs args, godot_variant& ret) in /home/aallard/Repositories/the-guild/Project/Godot.SourceGenerators/Godot.SourceGenerators.ScriptMethodsGenerator/View.Player_ScriptMethods.generated.cs:50
    <internal calls>
- [x] Improve the custom TraceListener to display all kind of log propertly (for example TraceError is not logged as a Godot error). - [ ] Configure a log category. - [x] Add verbose level (change default depending on the build/editor) - [x] Display /path/to/file:lineNumber instead of /path/to/file: line lineNumber (this allow to directly click on the path in vscode). # Assert Current behavior: Stack traces are displayed manually to follow these options: - hideInternalCalls: Don't display godot internal calls (C# and native). Keep source generator calls. - relativePath: display `res://Sources/View/Player.cs:24` instead of `/home/aallard/Repositories/the-guild/Project/Sources/View/Player.cs:24` Example with hideInternalCalls set to `true`: ``` Assertion failed. at View.Player._Process(Double delta) in /home/aallard/Repositories/the-guild/Project/Sources/View/Player.cs:24 <internal calls> at View.Player.InvokeGodotClassMethod(godot_string_name& method, NativeVariantPtrArgs args, godot_variant& ret) in /home/aallard/Repositories/the-guild/Project/Godot.SourceGenerators/Godot.SourceGenerators.ScriptMethodsGenerator/View.Player_ScriptMethods.generated.cs:50 <internal calls> ``` # Exceptions Current behavior: ``` Exception thrown: 'System.NullReferenceException' in TheGuild ERROR: System.NullReferenceException: Object reference not set to an instance of an object. at View.Player._Process(Double delta) in /home/aallard/Repositories/the-guild/Project/Sources/View/Player.cs:line 25 at Godot.Node.InvokeGodotClassMethod(godot_string_name& method, NativeVariantPtrArgs args, godot_variant& ret) in /root/godot/modules/mono/glue/GodotSharp/GodotSharp/Generated/GodotObjects/Node.cs:line 2111 at Godot.Node3D.InvokeGodotClassMethod(godot_string_name& method, NativeVariantPtrArgs args, godot_variant& ret) in /root/godot/modules/mono/glue/GodotSharp/GodotSharp/Generated/GodotObjects/Node3D.cs:line 1035 at View.Player.InvokeGodotClassMethod(godot_string_name& method, NativeVariantPtrArgs args, godot_variant& ret) in /home/aallard/Repositories/the-guild/Project/Godot.SourceGenerators/Godot.SourceGenerators.ScriptMethodsGenerator/View.Player_ScriptMethods.generated.cs:line 50 at Godot.Bridge.CSharpInstanceBridge.Call(IntPtr godotObjectGCHandle, godot_string_name* method, godot_variant** args, Int32 argCount, godot_variant_call_error* refCallError, godot_variant* ret) in /root/godot/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/CSharpInstanceBridge.cs:line 24 at: void Godot.NativeInterop.ExceptionUtils.LogException(System.Exception) (/root/godot/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/ExceptionUtils.cs:112) Assertion failed. at View.Player._Process(Double delta) in /home/aallard/Repositories/the-guild/Project/Sources/View/Player.cs:24 <internal calls> at View.Player.InvokeGodotClassMethod(godot_string_name& method, NativeVariantPtrArgs args, godot_variant& ret) in /home/aallard/Repositories/the-guild/Project/Godot.SourceGenerators/Godot.SourceGenerators.ScriptMethodsGenerator/View.Player_ScriptMethods.generated.cs:50 <internal calls> ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
simple-frogs/godot-starter-project#1
No description provided.