Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'print_rich' saves text to log with tags converted to ANSI symbols what makes closing tags unreadable. #79508

Closed
RonYanDaik opened this issue Jul 15, 2023 · 2 comments · Fixed by #90900

Comments

@RonYanDaik
Copy link

RonYanDaik commented Jul 15, 2023

Godot version

4.1

System information

Win 10

Issue description

When using print_rich to print some logs.

This is what log looks like in godot:
image

This is how its is saved in log file:

0:[color=deepSkyBlue][gds]:>�[39m[color=palegreen][S]:>�[39m[mi:1|a:1]:>[color=gold]W:�[39m �[1mTheGameState:[Wrapped:0]�[22m:> gameUnitSpawner.spawn_path:../Units
1:[color=deepSkyBlue][gds]:>�[39m[color=palegreen][S]:>�[39m[mi:1|a:1]:>[color=gold]W:�[39m �[1mTheGameState:[Wrapped:0]�[22m:> No 'Players' node. Creating.
2:[color=deepSkyBlue][gds]:>�[39m[color=palegreen][S]:>�[39m[mi:1|a:1]:>[color=firebrick]E:�[39m �[1mTheGameState:[Wrapped:0]�[22m:> Cant find Players MultiplayerSpawner with namePlayersSpawner
[bgcolor=palegreen]�[30m[Serv]:>�[39m�[49m �[1mTheGameState:[Wrapped:0]�[22m:>No 'Players Spawner (miltiplayer)' node. Creating. 
3:[color=deepSkyBlue][gds]:>�[39m[color=palegreen][S]:>�[39m[mi:1|a:1]:>[color=gold]W:�[39m �[1mTheGameState:[Wrapped:0]�[22m:> PlayersSpawner.spawn_path:../Players
4:[color=deepSkyBlue][gds]:>�[39m[color=palegreen][S]:>�[39m[mi:1|a:1]:>[color=gold]W:�[39m �[1mTheGameState:[Wrapped:0]�[22m:> gravity 9.8

This is how it is displayed when i try to read it from log file and draw it with RichTextLabel:
image

Expected behavior:
Closing tags printed as text, not as ANSI symbols.

Steps to reproduce

Print something with print_rich and them open log file.

Minimal reproduction project

N/A

@RonYanDaik RonYanDaik changed the title 'print_rich' saves text to log with tags converted to ANSI simbols what makes opening tags unreadable. 'print_rich' saves text to log with tags converted to ANSI simbols what makes closing tags unreadable. Jul 15, 2023
@Calinou
Copy link
Member

Calinou commented Jul 15, 2023

RotatedFileLogger (but not StdLogger) should be modified to strip ANSI escape codes in the saved files. See #77263 for an example of a PR that modifies logger classes.

Note that if you want color code conversion to work perfectly, you should only use the basic ANSI colors: black, red, green, yellow, blue, magenta, cyan, white. Support for named HTML colors and 24-bit color codes is planned, but it requires rewriting the BBCode to ANSI conversion logic from scratch.

@AThousandShips AThousandShips changed the title 'print_rich' saves text to log with tags converted to ANSI simbols what makes closing tags unreadable. 'print_rich' saves text to log with tags converted to ANSI symbols what makes closing tags unreadable. Jul 15, 2023
@Calinou
Copy link
Member

Calinou commented Apr 19, 2024

I can still reproduce this as of 4.3.dev b091162 (Linux).

@akien-mga akien-mga added this to the 4.3 milestone Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants