Adding this mostly for my own documentation, but maybe somebody else would find this useful.
I’ve got a standard DEBUG() function which I can turn on/off with a Virtual State device switch in UI4 to keep my logs from growing permanently and only output to the logs for troubleshooting while I’m looking/interested.
Step 0: Upload (install) the .xml files for the State Device to your Vera[1]
Step 1: Create a “Debug” device in “MIOS Developers” → “Create Device” using the “StateDevice.xml”
Step 2: Note the device ID in the “Advanced” tab for your new Debug device
Step 3: Add the following to the code window in “MIOS Developers” → “Edit Startup Lua”
Make sure to replace the [DEVICE ID] with the DevID number you identified in step 2.
devID_DebugState = [DEVICE ID]
--
function logMsg(message, l_dbg)
local showDBG = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1","Status", devID_DebugState)
local logTxt = "Debug: "
if ((showDBG == "1"))
then
logTxt = logTxt .. message
luup.log(logTxt)
end
end
Step 4: Click “Go”
Step 5: Click “Save” on the main UI4 page
Step 6: Restart Luup/Lua (The “circle arrows” on the main page) a couple-three times (until the device appears correctly).
Step 7: Use logMsg(“Message to log”) wherever you want to add some debug text in any Luup/Lua code.
The Debug output (prefixed with "Debug: ") will appear in your LuaUPnP.log file (/var/log/cmh) as long as the “Debug” device is “on”.
Hth
@sjolshagen
[1] = There are device files for download [url=http://forum.micasaverde.com/index.php?topic=6375.msg40051#msg40051]http://forum.micasaverde.com/index.php?topic=6375.msg40051#msg40051[/url] or [url=http://forum.micasaverde.com/index.php?topic=2138.msg9104#msg9104]http://forum.micasaverde.com/index.php?topic=2138.msg9104#msg9104[/url])