custom-components / pyscript

Pyscript adds rich Python scripting to HASS
Apache License 2.0
874 stars 46 forks source link

failling to get debug in log file #448

Closed dominig closed 1 year ago

dominig commented 1 year ago

I have a script name roudrobin.py in the pyscript directory. I cannot get log at debug or info level just for that script. from the documentation and forum I understand that the two following config should work but nothing does it. Is the documentation in line with latest release ? Where do I get it wrong ? Is a full reboot the only way to change log level avec changing config.yaml

------------ from documentation ------- logger: default: critial logs: custom_components.pyscript.file.roundrobin: debug

-------------- from forum ------------------- logger: default: critial logs: custom_components.pyscript: debug

craigbarratt commented 1 year ago

Those forms should work (although you say your file is roudrobin.py and the logger path is roundrobin - I presume that's just a typo_. I'm not sure when/whether HASS will reload its configuration file. Have you tried restarting HASS?

BTW, github issues are for reporting bugs or feature requests. These topics are more appropriate for discussions.

dominig commented 1 year ago

I am afraid that it might just a documentation error. If you follow the documentation and have a file name roundrobin.py you debug configuration should be: custom_components.pyscript.file.roundrobin: debug

The .py is clearly out in the documentation as you can see in the attached screenshot. Screenshot_20230312_195749

To be honest I have tried several option and I could not get it to work. It would be nice to know from the documentation how to get debug operational including understanding what needs reload to get the new config active.

craigbarratt commented 1 year ago

Setting logging levels for pyscript files and functions works correctly. I just tested it again.

If you are using Jupyter or VSC, you can set the logging levels by calling the logger.set_level service, eg:

logger.set_level(**{"custom_components.pyscript.file.my_script": "debug"})

will change the log level for the my_script.py script to debug.

Alternatively, you can use the HASS UI Developer Tools to call the logger.set_level service with the logging paths you want to change.

ALERTua commented 1 year ago

@dominig could you please update or close the issue? Thank you