New Docs on Logging

Just a quick note to let everyone know that we’ve added a docs page for logging in SmartApps or Device Types!

http://docs.smartthings.com/en/latest/introduction/introduction-to-the-ide/logging.html

Hat tip to @unixbeast, who wrote this page!

2 Likes

Very helpful addition to the docs… thanks! – Especially the examples, like try...catch.

One question / suggestion though… The table describing the suggested (?) use of the various Logging Levels is helpful, but I wonder if the standard could be more comprehensive.

For example, the documentation goes on to say that log trace messages could be coming and intermingled from both our code as well as “from the SmartApp framework”.

Perhaps if messages from the “framework” had their own tag “log.framework()” (?) … then this intermingling would be less confusing.

Alternatively, as a suggestion, I use a “cover method” for log.*() which results in longer messages but they are each tagged with the name (instance label name and app name) of the SmartApp.

This is particularly helpful when viewing multiple trace outputs from various concurrent sources in on the “Live Logging” screen.

private def myInfo(text) {
    log.info myLogFormat(text)
}
private def myLogFormat(text) {
    return "\"${app.label}\".(\"${app.name}\"): ${text}"
}

Just want to confirm that the logging is only valid if you are running the code in the IDE Right ?

Logging happens regardless of executing in the IDE or installed via the mobile app.

The logged messages are viewable in the IDE via the Live Logging view, or in the console window of the simulator if executing in the IDE.

2 Likes

@Jim - Once ST migrates to hubV2 will the logging be visible on the IDE for a smart app, even if the app runs locally on the Hub? or will it only be visible for apps that run on the cloud?

1 Like