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

Uses no color in Jupyter (may need to force TTY) #28

Open
Gerenuk opened this issue Jun 12, 2018 · 2 comments
Open

Uses no color in Jupyter (may need to force TTY) #28

Gerenuk opened this issue Jun 12, 2018 · 2 comments

Comments

@Gerenuk
Copy link

Gerenuk commented Jun 12, 2018

Daiquiri would also be great to use in Jupyter.
Unfortunately, it seems in Jupyter one usually has to enforce TTY mode in order to make color work.

There does not seem to be an option for that in daiquiri?

@jd
Copy link
Member

jd commented Jun 12, 2018

I never tried. Do you have some links or code sample you can share that can help understanding the issue and how to solve it?

@Gerenuk
Copy link
Author

Gerenuk commented Jun 24, 2018

I'm using the standard

import logging
import daiquiri
daiquiri.setup(level=logging.INFO, outputs=[daiquiri.output.STDOUT])
logger = daiquiri.getLogger(name)
logger.info("It works and log to stderr by default with color!")

in Jupyter notebook. The STDOUT is needed since Jupyter uses a red background for stderr.
It works correctly in consoles, but uses no color in Jupyter.

I noticed in some other terminal color libraries that enforcing TTY is important. For example

import coloredlogs, logging, sys
logger = logging.getLogger(name)
coloredlogs.install(level='DEBUG', stream=sys.stdout, isatty=True)

That isatty is key to really have colors in Jupyter. Somehow Jupyter does not identify itself as a proper TTY. Not sure what that means though.

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

No branches or pull requests

2 participants