DawnGroveStudios / GodotLogger

gdscript plugin to add a logger equivalent to the zap logger in go
MIT License
33 stars 8 forks source link

Logged dictionaries don't preserve key and value types #9

Closed Chrisknyfe closed 1 year ago

Chrisknyfe commented 1 year ago

When logging ints, floats, booleans and null, their types are not preserved and instead they are converted to strings.

This code:

class InventoryItem extends Resource:
    @export var itemtype: int = 0
    @export var metadata: Dictionary = {}
    @export var quantity: int = 1

func _ready():
    var d = {
        "foobar": "bazqux",
        5: 25,
        3.14: 12e3,
        true: false,
        null: null,
        "an object": InventoryItem.new(),
    }
    GodotLogger.info("this is an array", d)

results in the following output: INFO [21/9/2023 22:57:53] this is an array {"foobar":"bazqux","5":"25","3.14":"12000","true":"false","<null>":"<null>","an object":"{"itemtype":0,"metadata":{},"quantity":1,"resource_local_to_scene":false,"resource_name":"","resource_path":""}"}

Seann-Moser commented 1 year ago

I have just merged your changes and will add this to the next release! Should be out on the asset store by tomorrow