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

bisync: coloring in the logs not obeying --color or redirection #7771

Open
ncw opened this issue Apr 16, 2024 · 1 comment
Open

bisync: coloring in the logs not obeying --color or redirection #7771

ncw opened this issue Apr 16, 2024 · 1 comment

Comments

@ncw
Copy link
Member

ncw commented Apr 16, 2024

The coloring of the bisync logs isn't working the same as the coloring in the rest of rclone.

The coloring is supposed to be removed when you write to a file or it isn't supported. On Windows the coloring is done a completely different way (not with escape codes, except on Windows 10 or greater I think).

That is why we see this sort of thing in the log

2024/04/16 01:17:44 �[36m(01)  :�[0m �[34mtest extended-char-paths�[0m

If we were using terminal.Out to write to the terminal then this would be working properly and the coloring would also be obeying

 --color AUTO|NEVER|ALWAYS   When to show colors (and other ANSI codes) AUTO|NEVER|ALWAYS (default AUTO)

We are however using colors in rclone's logging system which was never intended to work like that! We probably want to continue using the log system for bisync so we need an official way of introducing colors into the log.

To fix that we could potentially make a new set of terminal colors, so log.RedFg() say (in fs/log) which is a function which will return empty string instead of the escape sequence as appropriate.

What do you think @nielash ?

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.
@nielash
Copy link
Collaborator

nielash commented Apr 16, 2024

bisync should be respecting --color. Are you able to reproduce it outside of the tests? On the tests we deliberately hard-code ALWAYS so that the colors themselves are tested (any unexpected color differences are reported as failures):

bisync.Colors = true

We are however using colors in rclone's logging system which was never intended to work like that! We probably want to continue using the log system for bisync so we need an official way of introducing colors into the log.

To fix that we could potentially make a new set of terminal colors, so log.RedFg() say (in fs/log) which is a function which will return empty string instead of the escape sequence as appropriate.

I stumbled over that a few months ago and added this as a quick fix: 8d3bcc0

But I agree it would be better to handle this more properly in fs/log. I think your idea sounds good (if I'm understanding it correctly!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants