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

Add option to change or disable colors #155

Open
Joyen12 opened this issue Sep 26, 2023 · 6 comments
Open

Add option to change or disable colors #155

Joyen12 opened this issue Sep 26, 2023 · 6 comments

Comments

@Joyen12
Copy link

Joyen12 commented Sep 26, 2023

For people having problem with colors like me it is very important.
Because with the default pretty print colors I can barely see what is written, I have to make a big effort to read it.
So I would better prefer just disable the colors all together. Or choosing the colors would be great also.

I guess adding the option to disable colors is easy. It would be very nice if someone could quickly implement this.

Thanks a lot

@fanoway
Copy link

fanoway commented Oct 7, 2023

I have the same issue. As far as I am aware this is not currently implemented. You could manually create this context manager I believe to implement this behavior (stolen from the unittests). Its not ideal if you want to disable it for the whole file.

from contextlib import contextmanager

from icecream import ic, stderrPrint

@contextmanager
def disableColoring():
    originalOutputFunction = ic.outputFunction

    ic.configureOutput(outputFunction=stderrPrint)
    yield
    ic.configureOutput(outputFunction=originalOutputFunction)

ic("This has coloring")
with disableColoring():
    ic("This has no coloring!)
ic{"This has coloring again") ```

@fanoway
Copy link

fanoway commented Oct 7, 2023

Also found this suggestion which might work better

import sys
from icecream import ic

ic.configureOutput(outputFunction=lambda *a: print(*a, file=sys.stderr))

@fanoway
Copy link

fanoway commented Oct 7, 2023

Made a PR to implement this feature

#157

@Joyen12
Copy link
Author

Joyen12 commented Oct 13, 2023

Ok , Thanks a lot. Having the ability to choose color would be the best , I really hope they implement it.
For now I will try just that. Thank you @fanoway

@bialix-electronicus
Copy link

bialix-electronicus commented Nov 3, 2023

On Windows the colors are really buggy. I want to turn them off immediately.

@salabim
Copy link

salabim commented Nov 3, 2023

Try ycecream:
pip install ycecream
Github:
https://github.com/salabim/ycecream

You will love it!

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

4 participants