gabime / spdlog

Fast C++ logging library.
Other
22.89k stars 4.34k forks source link

ANSI escape sequences multiplatform (win10, linux) #3111

Closed yalov closed 1 week ago

yalov commented 1 week ago

Hello, It there a way to have colors set up as

trace and debug — full line gray (GRAY = "\033[90m"), not just from %^ to %$, but full line

info, warn, error, critical — full line white (normal), only the level tag is colored (default colors and a pattern se up as %^%l%$ are ok)

tt4g commented 1 week ago

Related #3103

wincolor_sink is already provided that uses the old Windows color output API. However, wincolor_sink does not use ANSI escape sequences, so you can create a custom sink if you really want to use it.

See wiki: https://github.com/gabime/spdlog/wiki/4.-Sinks#implementing-your-own-sink

stdout_color_sink and stderr_color_sink, introduced in README.md, are aliases for ansicolor_sink and wincolor_sink.

https://github.com/gabime/spdlog/blob/c3aed4b68373955e1cc94307683d44dca1515d2b/include/spdlog/sinks/stdout_color_sinks.h#L14-L27