Added debug mode for more verbose logging

Also had to rename the existing DEBUG consts to DEVMODE, so as to not
confuse the two. DEVMODE is meant for developers and cannot be enabled
on-the-fly, whereas debug mode is for users to check that the bridge is
working, MQTT messages are received etc.

Update logging is throttled to avoid spurious messages for uncoalesced
MQTT updates and motion sensors. On my network with 10 devices, an
update is logged every 1-2 minutes on average.
This commit is contained in:
Darell Tan
2023-08-03 21:32:14 +08:00
parent 54aa0795c3
commit 3cfc3f68b0
3 changed files with 49 additions and 16 deletions

View File

@@ -26,6 +26,7 @@ var (
var (
configFile = flag.String("config", "/etc/hapz2m.conf", "config file")
dbPath = flag.String("db", "/var/lib/hapz2m", "db path")
debugMode = flag.Bool("debug", false, "enable debug messages")
)
type config struct {
@@ -70,6 +71,7 @@ func main() {
br.Server = cfg.Server
br.Username = cfg.Username
br.Password = cfg.Password
br.DebugMode = *debugMode
err = br.ConnectMQTT()
if err != nil {