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

Colors to logger #246

Open
ahoarau opened this issue Dec 1, 2017 · 1 comment
Open

Colors to logger #246

ahoarau opened this issue Dec 1, 2017 · 1 comment

Comments

@ahoarau
Copy link
Contributor

ahoarau commented Dec 1, 2017

I always found difficult to catch errors and/or warnings in the deployer.
Is it possible to add colors to to the Logger ?

Like red for Error and yellow for Warning.

@meyerj
Copy link
Member

meyerj commented Dec 5, 2017

Yes, that's possible and would be a nice extension. But the logger must detect whether the output is a terminal (e.g. using isatty) and whether it supports colors (e.g. using terminfo), and generate separate log lines for the console and output to a file.

I personally would only colorize the severity prefixes, like [ ERROR ] or [ Warning], but not the whole log line. Might be a matter of taste. And the stream modifiers to change color could be exposed in the Logger.hpp header file so that users can use them in log output if the terminal supports it, for example:

using namespace RTT;
log(Info) << "The word " << Logger::color_red() << "red" << Logger::color_normal() << " will be shown in red." << endlog();

Pull requests welcome ;-)

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

2 participants