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

Only log.error gets prints in jupyter notebook tutorial. log.debug produces no output. #18

Open
evelant opened this issue Nov 24, 2021 · 4 comments

Comments

@evelant
Copy link

evelant commented Nov 24, 2021

Trying out pyscript with the jupyter notebook tutorial and none of the log.debug messages print anything. I'm connected successfully and can read states but only log.errors prints results in the notebook and log.warn is not defined. I've never used jupyter before and have little python experience so I'm sorry if I've missed something obvious.

@r-j-taylor
Copy link

I'm in the same boat: little Python experience, no Jupyter experience. I noticed that my print statements are going to the core log for HA, or at least attempting to, which makes sense. But, it would be nice if there was an explanation in the README on how to redirect output to somewhere easily readable.

@zrsmithson
Copy link

I had a similar issue where log statements weren't printing, and I figured out it was due to the log level that the logging module sees. I think when loading the jupyter kernel, it's supposed to set the level to logging.DEBUG, but I think the following errors were due to it failing.

hass_pyscript_kernel: iopub_port c2k: read EOF; shutdown with exit_status=0
hass_pyscript_kernel: shell_port c2k: read EOF; shutdown with exit_status=0
hass_pyscript_kernel: control_port c2k: read EOF; shutdown with exit_status=0
hass_pyscript_kernel: stdin_port c2k: read EOF; shutdown with exit_status=0

Either way, I was able to get the logger myself and set the level and format string.

import logging
log_level = logging.DEBUG
logging.basicConfig(level=log_level, format="%(message)s")
logging.getLogger().setLevel(log_level)

In case there are any other effects, you can set a higher logging level, like logging.INFO or just print with log.info() or log.warning() (note that log.warn is a typo)

I didn't do any further debugging, but if it helps I'm running python 3.10.0 on MacOS, and running Home Assistant OS

@gosoares
Copy link

I'm facing the same issue. @zrsmithson suggestion also worked here.

@CorvetteCole
Copy link

I also see this same issue, although you have to enable arbitrary imports to import logging to change this in the first place

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

5 participants