I have started to setup a library that includes some methods I commonly use in my drivers to conditionally record different types of logging. I was able to add this library to the end of a new driver I am writing and see the code added to the end of a downloaded copy of the driver.
These methods also make use of preferences for the device, allowing the user to turn the different types of logging on or off. I expected I would need to setup a separate library, so I did this and added a second include statement to the meta-data section of the driver. I can see a reference in the libraries code page indicating this logging preferences library is being used by the driver, but no text is output in the driver.
Is this expected? If so, is there an alternative I could use?
To provide some more context, here are the two libraries:
library (
author: "Simon Burke",
category: "logging",
description: "Logging methods",
name: "loggingMethods",
namespace: "simnet",
documentationLink: ""
)
//Logging Utility methods
def debugLog(debugMessage) {
if (DebugLogging == true) {log.debug(debugMessage)}
}
def errorLog(errorMessage) {
if (ErrorLogging == true) { log.error(errorMessage)}
}
def infoLog(infoMessage) {
if(InfoLogging == true) {log.info(infoMessage)}
}
def warnLog(warnMessage) {
if(WarnLogging == true) {log.warn(warnMessage)}
}
def debugOff() {
log.warn("Disabling debug logging");
device.updateSetting("DebugLogging", [value:"false", type:"bool"])
}
def updated_debugTimout() {
if (DebugLogging) {
log.debug "updated: Debug logging will be automatically disabled in ${debugAutoDisableMinutes} minutes"
runIn(debugAutoDisableMinutes*60, "debugOff")
}
else { unschedule("debugOff") }
}
library (
author: "Simon Burke",
category: "logging",
description: "Logging preference settings",
name: "loggingPreferences",
namespace: "simnet",
documentationLink: ""
)
preferences {
// Logging Preferences
input(name: "DebugLogging", type: "bool", title:"Enable Debug Logging", displayDuringSetup: true, defaultValue: false)
input(name: "WarnLogging", type: "bool", title:"Enable Warning Logging", displayDuringSetup: true, defaultValue: true )
input(name: "ErrorLogging", type: "bool", title:"Enable Error Logging", displayDuringSetup: true, defaultValue: true )
input(name: "InfoLogging", type: "bool", title:"Enable Description Text (Info) Logging", displayDuringSetup: true, defaultValue: false)
}