CLI works

This commit is contained in:
Cody Lee
2022-12-22 18:16:43 -06:00
parent db9bcd5687
commit 3768c53512
16 changed files with 126 additions and 33 deletions

View File

@@ -14,7 +14,9 @@ func (u *InfluxUnifi) Logf(msg string, v ...any) {
Msg: fmt.Sprintf(msg, v...),
Tags: map[string]string{"type": "info"},
})
u.Collector.Logf(msg, v...)
if u.Collector != nil {
u.Collector.Logf(msg, v...)
}
}
// LogErrorf logs an error message.
@@ -24,7 +26,9 @@ func (u *InfluxUnifi) LogErrorf(msg string, v ...any) {
Msg: fmt.Sprintf(msg, v...),
Tags: map[string]string{"type": "error"},
})
u.Collector.LogErrorf(msg, v...)
if u.Collector != nil {
u.Collector.LogErrorf(msg, v...)
}
}
// LogDebugf logs a debug message.
@@ -34,5 +38,7 @@ func (u *InfluxUnifi) LogDebugf(msg string, v ...any) {
Msg: fmt.Sprintf(msg, v...),
Tags: map[string]string{"type": "debug"},
})
u.Collector.LogDebugf(msg, v...)
if u.Collector != nil {
u.Collector.LogDebugf(msg, v...)
}
}