Skip to content

prettier logging #450

@Qubus0

Description

@Qubus0

this includes prefixing the source file that started the log

static func log_prefix(stack) -> String:
    if len(stack) > 1:
        var call_site = stack[1]
        var basename = call_site["source"].get_file().get_basename()
        var line_num = str(call_site.get("line", 0))
        if call_site["source"].match("*/test/*"):
            return "{" + basename + ":" + line_num + "}: "
        elif call_site["source"].match("*/addons/*"):
            return "<" + basename + ":" + line_num + ">: "
        else:
            return "[" + basename + ":" + line_num + "]: "
    return ""

ref https://github.com/russmatney/log.gd/blob/main/addons/log/log.gd#L516-L527

and also print_rich when in the editor to use

  • colors for each log level and
  • reduce visual noise by hiding information like timestamps or
  • the mod loader log names within bbcode hint tags ([hint={tooltip text displayed on hover}]{text}[/hint])

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions