no problem @steve1, maybe the hair will grow out again (probably not)
Anyway, I’d like to send you a crate of European beers or something else to show you my gratitude for providing your framework to the community. I’ve heard you’ve only got Budweiser and Sol girl beer over there.
As I wrote before, I’m using your framework on OH 2.2 and I’m trying really hard to make things work using your examples that you’ve kindly bundled.
It’s hard for a newbie like me because there is something “eating” and hiding all the runtime error messages, That is, if I write something stupid like myVar = 8/0
in my scripts, the script will just stop. No error message in the the log whatsoever. I need to have my runtime error messages to show up in the log.
I’ve understood that OH build from November 10 #579 uses log4j instead of slf4j. Trying hard to figure out what’s going on under the hood, I’ve found out that openhab.log uses the old slf4j. Maybe that’s why things are not working so great for me here? Or maybe there is something in the default /var/lib/openhab2/etc/org.ops4j.pax.logging.cfg
that I need to configure before logs can be shown? If I should make a guess, (As a newbie I probably should avoid that) there is a try/catch block in the framework capturing all runtime errors and sending them to the log in a way that’s not compatible with my log4j logging so they just end up in /dev/null … That’s just a guess, I’m a newbie after all.
I see a great potential in your framework so I won’t give up easy.
Do you have any ideas what I should do Steve?
Cheers!
EDIT:
Here is an example script:
(I use logging.error because logging.info doesn’t show up in the log at all)
from openhab.log import logging
from openhab.triggers import time_triggered
logging.error('Who let the dogs out?')
@time_triggered("0/10 * * * * ?")
def my_periodic_function():
logging.error('Who let the cats out?')
myVar = 8/0
logging.error('This line will not show up in the log because the previous statement caused a runtime error')
Output in logfile:
9:21:18.354 [INFO ] [ort.internal.loader.ScriptFileWatcher] - Loading script 'test.py'
19:21:18.359 [ERROR] [ROOT ] - Who let the dogs out?
19:21:20.009 [ERROR] [ROOT ] - Who let the cats out?
But if I change my script a bit like this:
from openhab.log import logging
from openhab.triggers import time_triggered
logging.error('Who let the dogs out?')
myVar = 8/0
@time_triggered("0/10 * * * * ?")
def my_periodic_function():
logging.error('Who let the cats out?')
myVar = 8/0
logging.error('This line will not show up in the log because the previous statement caused a runtime error')
Log output is:
9:22:35.019 [INFO ] [ort.internal.loader.ScriptFileWatcher] - Loading script 'test.py'
19:22:35.024 [ERROR] [ROOT ] - Who let the dogs out?
19:22:35.026 [ERROR] [ript.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/test.py': ZeroDivisionError: integer divisionor modulo by zero in <script> at line number 5
Which is quite helpful for a newbie like me because I’ll be advised immediately that the script stopped and what the cause is.