Is GD.PrintRich in the custom logger is broken?

Godot Version

4.7.dev5

Question

I was making a console and encountered this strange behavior:

“THIS TEXT IS BOLD!!!” is printed using GD.PrintRich(), the rest is printed using GD.Print(). The output of GD.Print() doesn’t surprise me, but GD.PrintRich() looks very strange. Why is that? For some reason, it tries to send text to the console for the system terminal with escape sequences, instead of BBCode.

The console logger code is as simple as a mouse.

public override void _LogMessage(string message, bool error)
{
    if (error)
        Console.Print(message, Console.LogLevel.Error);
    else
        Console.Print(message);
}

What should I do? Should I try to handle escape sequences or something else? Or is this just a bug?

btw, everything works fine in C++ (tested on modules)

Terminals usually accept escape sequences so printing rich text to the console will use terminal escape sequences, probably based on your how your terminal accepts sequences too. You will have to convert or remove escape sequences for the logs to show in a RichTextLabel

Rich text as an idea doesn’t mean BBCode, just that the text is supplemented in some way. RichTextLabels choose to enhance text with BBCode as it’s easy to read, write, and extend; where escape sequences are not.

1 Like