mirror of
https://github.com/nikdoof/hapz2m.git
synced 2026-01-30 11:38:22 +00:00
Added quiet mode for reduced verbosity
This is useful to reduce clutter if you're running the service and it's writing logs to the main syslog.
This commit is contained in:
@@ -56,6 +56,7 @@ type Bridge struct {
|
|||||||
Interfaces []string
|
Interfaces []string
|
||||||
|
|
||||||
DebugMode bool
|
DebugMode bool
|
||||||
|
QuietMode bool
|
||||||
|
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
bridgeAcc *accessory.Bridge
|
bridgeAcc *accessory.Bridge
|
||||||
@@ -561,7 +562,7 @@ func (br *Bridge) UpdateAccessoryState(devName string, payload []byte) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if br.DebugMode || time.Since(dev.LastSeen) > 30*time.Second {
|
if br.DebugMode || (!br.QuietMode && time.Since(dev.LastSeen) > 30*time.Second) {
|
||||||
log.Printf("received update for device %q", devName)
|
log.Printf("received update for device %q", devName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ var (
|
|||||||
configFile = flag.String("config", "/etc/hapz2m.conf", "config file")
|
configFile = flag.String("config", "/etc/hapz2m.conf", "config file")
|
||||||
dbPath = flag.String("db", "/var/lib/hapz2m", "db path")
|
dbPath = flag.String("db", "/var/lib/hapz2m", "db path")
|
||||||
debugMode = flag.Bool("debug", false, "enable debug messages")
|
debugMode = flag.Bool("debug", false, "enable debug messages")
|
||||||
|
quietMode = flag.Bool("quiet", false, "reduce verbosity by not showing received upates")
|
||||||
)
|
)
|
||||||
|
|
||||||
// config struct
|
// config struct
|
||||||
@@ -77,6 +78,11 @@ func main() {
|
|||||||
br.Username = cfg.Username
|
br.Username = cfg.Username
|
||||||
br.Password = cfg.Password
|
br.Password = cfg.Password
|
||||||
br.DebugMode = *debugMode
|
br.DebugMode = *debugMode
|
||||||
|
br.QuietMode = *quietMode
|
||||||
|
|
||||||
|
if *debugMode && *quietMode {
|
||||||
|
log.Fatalf("-quiet and -debug options are mutually-exclusive")
|
||||||
|
}
|
||||||
|
|
||||||
// validate ListenAddr if specified
|
// validate ListenAddr if specified
|
||||||
if cfg.ListenAddr != "" {
|
if cfg.ListenAddr != "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user