Centralized logging facility for the Grid Building plugin. [b]Static singleton API (preferred):[/b] [codeblock] # Once, during plugin initialization: PlacementLogger.initialize(debug_settings) ## # Or push a scoped override for a sub-region (tests, plugins): PlacementLogger.push_scope(custom_logger) # ... do work ... PlacementLogger.pop_scope() # Anywhere in the plugin — zero boilerplate, zero null checks: PlacementLogger.debug("msg") PlacementLogger.trace("msg") PlacementLogger.warn("msg") PlacementLogger.error("msg") [/codeblock] [b]Overriding the logger at game time:[/b] Game developers can replace the global emitter by calling [method initialize] again at any point — that replaces the production root. For bounded overrides (a single test, a single plugin sub-region) prefer [method push_scope] / [method pop_scope] so the override auto-cleans when the scoped region exits. [b]Test isolation:[/b] Tests call [method push_scope] in before_test and [method pop_scope] in after_test to substitute the production emitter with a muted or spy logger for the duration of one test. Sequential GdUnit4 execution keeps the stack consistent across tests. [b]Instance API (still available for backward compat):[/b] [code]logger.log_debug("msg")[/code] USAGE: Consider dropping log level on the PlacementDebugSettings if you are getting too many messages Responsibilities:
- Provide contextual logging (verbose, error, warning) integrated with plugin debug settings.
- Support dependency-injected configuration and throttled verbose output.
Source: addons/grid_placement/logging/placement_logger.gd
Syntax
class PlacementLogger extends RefCounted