nil guard when disabled datadog plugin for logging

This commit is contained in:
Cody Lee 2022-11-23 18:07:38 -06:00 committed by GitHub
parent facec3f323
commit 2164d6f502
1 changed files with 9 additions and 3 deletions

View File

@ -2,15 +2,21 @@ package datadogunifi
// Logf logs a message.
func (u *DatadogUnifi) Logf(msg string, v ...interface{}) {
u.Collector.Logf(msg, v...)
if u.Collector != nil {
u.Collector.Logf(msg, v...)
}
}
// LogErrorf logs an error message.
func (u *DatadogUnifi) LogErrorf(msg string, v ...interface{}) {
u.Collector.LogErrorf(msg, v...)
if u.Collector != nil {
u.Collector.LogErrorf(msg, v...)
}
}
// LogDebugf logs a debug message.
func (u *DatadogUnifi) LogDebugf(msg string, v ...interface{}) {
u.Collector.LogDebugf(msg, v...)
if u.Collector != nil {
u.Collector.LogDebugf(msg, v...)
}
}