erebe / wstunnel

Tunnel all your traffic over Websocket or HTTP2 - Bypass firewalls/DPI - Static binary available
Other
3.22k stars 290 forks source link

Feature request: no ANSI color when logging to a pipe/file #197

Closed leahneukirchen closed 4 months ago

leahneukirchen commented 5 months ago

Is your feature request related to a problem? Please describe.

wstunnel prints ANSI codes in the log messages, even if the logs don't go to a console. This results in escape sequences in log files.

Describe the solution you'd like

wstunnel should use isatty(2) to determine whether to use coloring in logs. It's probably enough to remove .with_ansi(true), as colors are enabled by default https://docs.rs/tracing-subscriber/latest/tracing_subscriber/fmt/struct.Layer.html#method.with_ansi but can then be disabled by setting NO_COLOR.

Describe alternatives you've considered

Alternatively a flag could be provided.

Setting RUST_LOG_STYLE did not work for me.

erebe commented 5 months ago

Hello,

Thanks for reporting, I am going to remove the line and add a comment in the CLI to let know the option exist. Should land tomorrow, I don't have that much time today.

leahneukirchen commented 5 months ago

Thanks, no hurry!

erebe commented 5 months ago

Should be good in new release https://github.com/erebe/wstunnel/releases/tag/v8.4.2

You can set the env var NO_COLOR or use the flag --no-color to disable color output https://github.com/erebe/wstunnel/commit/89c840539686e489bc5f7faae94751bb12b725d6

Enjoy :)