raldone01 / godot_addon_gdlogging

Logging addon for godot 4
MIT License
12 stars 0 forks source link

Plugin does not load correctly (at least in Godot4.3 betas) #5

Closed smedelyan closed 4 months ago

smedelyan commented 4 months ago

Subj. It seems they have made some changes / improvements in 4.3. Now I can observe the following scenario:

This is not an issue if I replace Log in logger.gd with a reference to a static field, e.g.:

# Copyright (c) 2024 The gdlogging Contributors
# Inspired by https://github.com/KOBUGE-Games/godot-logger/blob/master/logger.gd
@tool
class_name CLog # <--- added class_name to reference static field
extends Node

# ...

static var _log_instance: CLog # <-- static field as an alterntative to referencing Log autoload

#...

    func write_bulks(p_log_records: Array[Dictionary], p_formatted_messages: PackedStringArray) -> void:
                # all Log.* references changed to CLog._log_instance
        CLog._log_instance._logger_direct_console.warning("LogSink: write_bulks() not implemented.")
#...

func _init() -> void:
    _global_broadcast_sink = BroadcastPipe.new()
    var log_formatter := LogRecordFormatter.new()
    _global_logger = Logger.new("Global", LogLevel.TRACE, log_formatter, _global_broadcast_sink)
    _logger_direct_console = Logger.new("gdlogging", LogLevel.TRACE, log_formatter, ConsoleSink.new())
    if Engine.is_editor_hint():
        add_sink(ConsoleSink.new())
    _log_instance = self # <----------------- added this line
raldone01 commented 4 months ago

I can not reproduce this issue with Godot Engine v4.3.beta2.mono.official.b75f0485b. Test godot project: https://github.com/raldone01/godot_addon_gdlogging_test

smedelyan commented 4 months ago

Hmmm, I also cannot reproduce it in clean project with v4.3.beta2.official [b75f0485b]. Maybe this is related to editor cache or something as on my main project this was blocking me (same Godot version).

Closing the issue for now, thank you for quick response