Hubitat supplies sample code, as you know, at their github. I grabbed a chunk of code that acts as a reminder for when I need to add it to custom code...
preferences {
input name: "debugOutput", type: "bool", title: "Enable debug logging?", defaultValue: true
input name: "txtEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: true
> def updated() {
> unschedule()
> if (debugOutput) runIn(1800,logsOff)
>
> def logsOff(){
> log.warn "debug logging disabled..."
> log.warn "description logging is: ${txtEnable == true}"
> device.updateSetting("debugOutput",[value:"false",type:"bool"])
> }
>
> // change log.debug to logDebug THEN add this (which has a needed log.debug)
>
> private logDebug(msg) {
> if (settings?.debugOutput || settings?.debugOutput == null) log.debug "$msg"
> }
>
> if (txtEnable) log.info
at the bottom of the preferences section, add the line for the toggle.
In the updated method, after an unsubscribe, add the runIn(1800 line (auto shuts debug in 30 mins.)
Add the logsOff method
Then change every occurrence of "log.debug" to logDebug
THEN add the private logDebug method (it will be the only 'legitimate' log.debug in the entire code.
For an APP... change:
device.updateSetting("debugOutput",[value:"false",type:"bool"])
to
app?.updateSetting("debugOutput",[value:"false",type:"bool"])