I'm using Boost.Log V2 1.75.0 and setting up my environment from configuration file by using boost::log::init_from_stream(config);
Is it possible to declare colored console sink trough configuration file or is there any way add colored output to the console?
Now, I add as many Console sink as many log level available in Boost Trivial Logger and filter them by distinct level, but I don't think, that this is the right way. Example:
[Sinks.ConsoleSinkTrace]
Destination=Console
Filter="%Severity% = trace"
Format="\033[0;35m[%TimeStamp%] [%ProcessId%] [%ThreadId%] [%Severity%] - %Message%\033[0m"
Asynchronous=false
AutoFlush=true
[Sinks.ConsoleSinkDebug]
Destination=Console
Filter="%Severity% = debug"
Format="\033[0;34m[%TimeStamp%] [%ProcessId%] [%ThreadId%] [%Severity%] - %Message%\033[0m"
Asynchronous=false
AutoFlush=true
... and so on...
Update
I have found the SO post suggested by @AndreySemashev, but I don't really understand, how can I accommodate it into my project: My key expectation is that I want to configure Boost.Log via file, so:
- if I delete console sink from config file at all, how to set the formatter to the sink? (I guess
sink
is a Console type sink that won't be instantiated if there is no such section in the config file)
sink->set_formatter(&coloring_formatter);
- if I provide a new formatter method, I assume, that handling the entire format string given in the config file is my responsible. I would like to avoid this too
Are these observations correct, or do I miss something?
Thank you