Add debug flag to adjust log verbosity a bit

Not as good as a proper logging system, but still provids a bit of
control over log verbosity
This commit is contained in:
Ian Fijolek
2019-10-04 16:05:25 -07:00
parent f99ee9891e
commit ac8ab9ef43
4 changed files with 34 additions and 13 deletions
+15 -9
View File
@@ -67,9 +67,13 @@ func (monitor *Monitor) Check() (bool, *AlertNotice) {
alertNotice = monitor.failure()
}
// log.Printf("DEBUG: Command output: %s", monitor.lastOutput)
if LogDebug {
log.Printf("DEBUG: Command output: %s", monitor.lastOutput)
}
if err != nil {
log.Printf("DEBUG: Command result: %v", err)
if LogDebug {
log.Printf("DEBUG: Command result: %v", err)
}
}
log.Printf(
@@ -102,13 +106,15 @@ func (monitor *Monitor) failure() (notice *AlertNotice) {
monitor.failureCount++
// If we haven't hit the minimum failures, we can exit
if monitor.failureCount < monitor.getAlertAfter() {
log.Printf(
"DEBUG: %s failed but did not hit minimum failures. "+
"Count: %v alert after: %v",
monitor.Name,
monitor.failureCount,
monitor.getAlertAfter(),
)
if LogDebug {
log.Printf(
"DEBUG: %s failed but did not hit minimum failures. "+
"Count: %v alert after: %v",
monitor.Name,
monitor.failureCount,
monitor.getAlertAfter(),
)
}
return
}