Skip to content

Add Debug to properties.yml#364

Open
tayjay wants to merge 6 commits intonorthwood-studios:masterfrom
tayjay:debug-logging-property
Open

Add Debug to properties.yml#364
tayjay wants to merge 6 commits intonorthwood-studios:masterfrom
tayjay:debug-logging-property

Conversation

@tayjay
Copy link

@tayjay tayjay commented Mar 1, 2026

Notice to Plugin Developers

Not a breaking change, but developers that have not explicitly set canBePrinted to true in their Logger.Debug calls will not see [DEBUG] message in the Console until debug is set true in configs/{PORT}/{Plugin}/properties.yml. Existing custom Debug configs will still work if prefered.

Changes

  • Adds bool debug to plugins' properties.yml to control default Debug log behaviour.
    • Logger.Debug(object) will check for this Debug value before printing.
    • Logger.Debug(object,bool) will override the Debug check.
    • debug value is updated when Properties are loaded on initial LabAPI load.
  • Adds LabAPIConfig bool debug_override, if set true will force all Debugs to display, unless overrode by Logger.Debug(object,bool)

Notes

Purpose is to prevent console spam of unhandled Debug calls when a plugin is published.

Same names from EXILED were only used to improve experience of developers adopting LabAPI. Implementation is custom but used most optimal patterns if it matched theirs.

Updating the Debug property could be handled on Per-Plugin reload but wanted to reduce changes first time around.

tayjay added 4 commits March 1, 2026 11:39
…ault behaviour

warn!: plugin developers must set `Debug` in `configs/{PORT}/{Plugin}/properties.yml` for [DEBUG] messages to appear unless they explictly set the `canBePrinted` parameter of the Debug method
Copy link
Collaborator

@davidsebesta1 davidsebesta1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

/// <summary>
/// Whether debug logs should appear regardless of pre-plugin properties.
/// </summary>
/// <seealso cref="LabApi.Loader.Features.Plugins.Configuration.Properties.Debug"/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See line 27, was following the same way LoadUnsupportedPlugins was commented.

/// Uses explicit <paramref name="canBePrinted"/>.
/// Can be replaced with the single parameter overload to use <see cref="LabApi.Loader.Features.Plugins.Configuration.Properties.Debug"/> Property instead.
/// </remarks>
public static void Debug(object message, bool canBePrinted)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forcing a parameter on devs is in fact, breaking change.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The overloaded Debug method on line 36 will be used if only 1 parameter is provided. So it is not forced, just explicitly defined. Plugins that are already built will have the default "true" parameter included automatically and the IL will point them to Logger::Debug(object,bool) which is present.

@tayjay
Copy link
Author

tayjay commented Mar 1, 2026

Overall on my code comments I was just wanting to be thorough on my reasoning on why I did each one. I'll do a bulk trim of them.

tayjay and others added 2 commits March 1, 2026 15:14
Co-authored-by: David <david.sebesta@post.cz>
fix: removing references to classes used in an old implementation from PluginLoader.cs
@tayjay
Copy link
Author

tayjay commented Mar 2, 2026

Thank you for the feedback. I have made the suggested revisions. :)

This change should be inert for plugins compiled for existing LabAPI versions. If the developer did not specify a second parameter the compiler will have included the default true (ldc.i4.1) before it calls

call void [LabApi]LabApi.Features.Console.Logger::Debug(object, bool)

With this change the 1 parameter overload would be used on new builds

call void [LabApi]LabApi.Features.Console.Logger::Debug(object)

The [opt] tag on the parameter in the current Debug method is not seen by the calling plugin. It will not be aware of its removal.


This does change the default behaviour of the Debug method, essentially replacing canBePrinted=true with canBePrinted=false and a config option to change it. I can see the rationale for this being a breaking change, but I feel that Debug off by default is better to get to eventually.

@tayjay tayjay requested a review from davidsebesta1 March 2, 2026 00:20
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.

2 participants