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

Expose is_colorized #45

Open
patlefort opened this issue Jun 8, 2020 · 2 comments
Open

Expose is_colorized #45

patlefort opened this issue Jun 8, 2020 · 2 comments
Labels

Comments

@patlefort
Copy link

Hi, it would be useful if the is_colorized function would be exposed outside the implementation detail namespace. That way I can know if it's safe to colorize into a transitory string (via stringstream for example) before outputing that string to a maybe colorized stream.

Small aside: while technically according to the standard your "_internal" namespace is valid, I would avoid anything that starts with an underscore.

@ikalnytskyi
Copy link
Owner

Hey @patlefort,

Sorry for taking me so long to respond to you. Would you mind to elaborate a little bit on your use case? I don't quite understand why someone would like to check whether a stream is color capable or not?

@patlefort
Copy link
Author

In the case of buffered output, if you want to buffer an output before sending it to a stream but I would like to know if it's safe to colorize it. Example: create an std::stringstream, output to it, then send the stringstream buffer to std::cout. I'd check if std::cout is colorized so I can set the stringstream colorized state with colorize. One use case is a logger in a multi-thread context. I think it make sense to expose it when you also have colorize and nocolorize.

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

No branches or pull requests

2 participants