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

log output appears to include terminal escape sequences even when stdout is not a tty #331

Open
jclulow opened this issue Oct 8, 2023 · 3 comments

Comments

@jclulow
Copy link

jclulow commented Oct 8, 2023

I am running the syncv3 binary with both stdout and stderr redirected to a file, and that file appears to contain colour escape sequences meant for a terminal:

synapse0 # cat -vet /var/svc/log/*ssproxy*
[ Oct  8 08:51:27 Disabled. ]$
[ Oct  8 08:51:27 Rereading configuration. ]$
[ Oct  8 08:51:37 Enabled. ]$
[ Oct  8 08:51:37 Executing start method ("/data/ssproxy/start"). ]$
Sync v3 [0.99.10] (d214047)$
Debug=false LogLevel= MaxConns=0$
2023/10/08 08:51:37 goose: no migrations to run. current version: 20230822180807$
^[[90m08:51:37^[[0m ^[[32mINF^[[0m creating handler$
^[[90m08:51:37^[[0m ^[[32mINF^[[0m retrieved global snapshot from database$
^[[90m08:51:37^[[0m ^[[32mINF^[[0m listening on 0.0.0.0:8009$
^[[90m08:51:37^[[0m ^[[32mINF^[[0m StartV2Pollers ^[[36mnum_devices=^[[0m1 ^[[36mnum_fail_decrypt=^[[0m0$

When stdout is not a tty, it would be good if the log output could just be plain text.

@dougluce
Copy link

#420 should address this via env var setting.

@jclulow
Copy link
Author

jclulow commented Apr 16, 2024

@dougluce An environment variable override doesn't fix this bug. The program needs to check if it's being run interactively, or is redirected to something that isn't a tty; e.g., a file or a pipe. In the case that it's not interactive, it must not emit any terminal control sequences by default.

One would use isatty(3C) for this check, or whatever the Go wrapper around that call is called, on whichever of stdout or stderr is the target of the logging stream.

@jclulow
Copy link
Author

jclulow commented Aug 6, 2024

This defect still exists as of Sync v3 [0.99.19] (f70dbe0).

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

2 participants