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

Logging always produces terminal escape sequences, even when printing to file or pipe #1747

Open
sleeptightAnsiC opened this issue Feb 11, 2025 · 0 comments

Comments

@sleeptightAnsiC
Copy link

sleeptightAnsiC commented Feb 11, 2025

Gamescope always produces logs with terminal sequences such as \e[0;34m and \e[0m, even when it prints them into non-tty (not an interactive terminal) such as file or pipe. This makes it hard to read those logs with text editor, or to parse them with external command.

Most command line utilities usually deal with this problem by checking stderr with isatty(3). In gamescope those sequences appear to be hard-coded here LogScope::log and here GetLogPriorityText

Repro:

$ git clone --recursive https://github.com/ValveSoftware/gamescope.git
$ cd gamescope
$ meson setup build/
$ ninja -C build/
$ build/src/gamescope -- wine winemine 2> sample.txt   # can be anything, I just used 'wine winemine'
$ xdg-open sample.txt

Result:

Image

Expected: Terminal escape sequences should be omitted in this case.

Enviroment:

$ build/src/gamescope --version
[gamescope] [Info]  console: gamescope version 3.16.1-39-gbafa157 (gcc 14.2.1)
$ uname -a
Linux MAL200424 6.13.2-arch1-1 #1 SMP PREEMPT_DYNAMIC Sat, 08 Feb 2025 18:54:55 +0000 x86_64 GNU/Linux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant