Repository navigation
Docs: logger names for scripts, apps and modules (#520) - #913
Conversation
The logging docs only showed the "file" path, so apps (and modules and scripts) were hard to configure, and they claimed Jupyter shows log output regardless of the logger settings, which isn't true. Add a table of logging paths per location, a full logger example, note where internal trigger messages are logged, and correct the Jupyter note in the reference and tutorial. Refs custom-components#821, custom-components#520, custom-components#265. Signed-off-by: Sean Stoube <[email protected]>
craigbarratt
left a comment
There was a problem hiding this comment.
Thanks @HoneyBearTech. The logger path table and the Jupyter correction are both accurate.
One fix: with the default (non-legacy) decorators, the "not active" message is Trigger not active due to .... It's logged at debug through the function's own logger (e.g. custom_components.pyscript.file.my_script.my_function), not under custom_components.pyscript.trigger. Only legacy_decorators: true uses trigger.py's trigger ... got ... trigger, but not active. Could you update that paragraph, and the note after the example, to match? Setting a script to debug shows these messages for its functions.
Optionally, you could also mention that files in subdirectories of scripts/ get dotted names, e.g. scripts.sub.NAME.
Signed-off-by: Sean Stoube <[email protected]>
|
@craigbarratt thanks for checking! I've updated both passages. One small difference from your suggestion: the Trigger not active due to ... message goes through the script's logger (e.g. custom_components.pyscript.file.my_script), not a function-qualified one. EvalFunc builds its logger from the global context name only (eval.py L335 and L377), and FunctionDecoratorManager reuses it (decorator.py L250). So setting just ...my_script.my_function to debug doesn't show it, but ...my_script does. The text now says that. I also added the note that files in subfolders of scripts/ get dotted names. |
craigbarratt
left a comment
There was a problem hiding this comment.
Thanks @HoneyBearTech, and you're right about the logger name: EvalFunc uses the global context's logger, so it's the script, not the function. Looks good.
|
Thanks! |
Closes #520, refs #821 and #265
What was missing
The logging docs only showed the
filepath, so it wasn't clear how to set the level for apps, modules orscripts/. The docs also said Jupyter shows log output regardless of the logger settings, which isn't what the code does.What I changed
docs/reference.rst:file.NAME,scripts.NAME,apps.APP,modules.MODULEandjupyter_NNN, all undercustom_components.pyscript;file;custom_components.pyscript.trigger);logger:example.docs/reference.rstanddocs/tutorial.rstnow says Jupyter shows the messages that pass the logger's level.Each path was checked against how the global contexts build their logger names.
Testing
sphinx-build -Wbuilds the docs with no warnings, and codespell is clean.