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

ANSI color sink on Windows #3138

Open
cschreib-ibex opened this issue Jul 17, 2024 · 0 comments
Open

ANSI color sink on Windows #3138

cschreib-ibex opened this issue Jul 17, 2024 · 0 comments

Comments

@cschreib-ibex
Copy link

Most modern terminals on Windows now support ANSI color codes (this includes, e.g., Windows Terminal, and the good old console if created with the appropriate flags; see ENABLE_VIRTUAL_TERMINAL_PROCESSING, starting from Windows 10). ANSI color codes have the advantage of being able to survive when stdout is piped, while Windows console color commands do not (in fact, the output is just lost if the colours are set to always).

Unfortunately:

  1. When using spdlog built as a shared or static library, the ansicolor_sink-inl.h is never included in the library, therefore simply trying to include ansicolor_sink.h and using the class results in linker errors. This can be worked around by including ansicolor_sink-inl.h explicitly.
  2. The ANSI color sink uses ::fwrite unconditionally, which results in double carriage returns being printed on Windows. This is the same issue as stdout sink produces extra carriage returns on Windows #1675, which applied to the regular stdout sink, but now applies to the ANSI sink. The solution would be to use the same fix here, namely, use ::WriteFile on Windows and ::fwrite on 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