mkbean wrote:1. Scripts seem to fail silently, particularly if they are run from a file and not "embedded python'", how can i catch these errors?
There's a straightforward way to do this. The following script is run from a file in an Indigo action:
- Code: Select all
"""
Example of how to access logger levels in linked and embedded scripts.
"""
indigo.server.log("debug", level=10)
indigo.server.log("info", level=20)
indigo.server.log("warning", level=30)
indigo.server.log("critical", level=40)
indigo.server.log("error", level=50)
mkbean wrote:2. How can i log to the indigo log in .py scripts that are in the Python3-includes folder, i can "print" which appears in the interactive console but thats as far as i've managed to get.
This example is a little bit more complex just to show what's possible. I've saved this script to the Python3-includes folder:
- Code: Select all
"""
Another example of how to access logger levels in linked and embedded scripts.
"""
import indigo # required, or you'll get a syntax error
import logging
indigo.server.log("debug message", level=logging.DEBUG)
indigo.server.log("info message", level=logging.INFO)
indigo.server.log("warning message", level=logging.WARNING)
indigo.server.log("error message", level=logging.ERROR)
indigo.server.log("critical message", level=logging.CRITICAL)
EDIT: ( saved as "logging_test.py" in the includes folder, then you "import logging_test" someplace else.)