docker.go: logging of events

Add log.IsEnabledFor(logging.DEBUG) guard to avoid unnecessary memory allocations. Debug level is usually disabled.
Inline "destroy"
This commit is contained in:
Sergey Ponomarev 2020-11-17 11:42:45 +02:00
parent 99d9aeec98
commit 5aacdc3772

View File

@ -2,6 +2,7 @@ package connector
import (
"fmt"
"github.com/op/go-logging"
"strings"
"sync"
@ -71,10 +72,14 @@ func (cm *Docker) watchEvents() {
switch actionName {
case "start", "die", "pause", "unpause", "health_status":
if log.IsEnabledFor(logging.DEBUG) {
log.Debugf("handling docker event: action=%s id=%s", e.Action, e.ID)
}
cm.needsRefresh <- e.ID
case "destroy":
log.Debugf("handling docker event: action=%s id=%s", e.Action, e.ID)
if log.IsEnabledFor(logging.DEBUG) {
log.Debugf("handling docker event: action=destroy id=%s", e.ID)
}
cm.delByID(e.ID)
}
}