refactor: reduce duplication in nameserver logging
and remove a dot import in the process
This commit is contained in:
1 parent
4c0fe7b006
commit
6e4f025d9c
1 file changed
+9
-4
@@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
"github.com/weaveworks/mesh"
|
"github.com/weaveworks/mesh"
|
||||||
|
|
||||||
. "github.com/weaveworks/weave/common"
|
"github.com/weaveworks/weave/common"
|
||||||
"github.com/weaveworks/weave/net/address"
|
"github.com/weaveworks/weave/net/address"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -230,12 +230,17 @@ func (n *Nameserver) OnGossipBroadcast(_ mesh.PeerName, msg []byte) (mesh.Gossip
|
|||||||
return entries, err
|
return entries, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Logging
|
||||||
|
|
||||||
func (n *Nameserver) infof(fmt string, args ...interface{}) {
|
func (n *Nameserver) infof(fmt string, args ...interface{}) {
|
||||||
Log.Infof("[nameserver %s] "+fmt, append([]interface{}{n.ourName}, args...)...)
|
n.logf(common.Log.Infof, fmt, args...)
|
||||||
}
|
}
|
||||||
func (n *Nameserver) debugf(fmt string, args ...interface{}) {
|
func (n *Nameserver) debugf(fmt string, args ...interface{}) {
|
||||||
Log.Debugf("[nameserver %s] "+fmt, append([]interface{}{n.ourName}, args...)...)
|
n.logf(common.Log.Debugf, fmt, args...)
|
||||||
}
|
}
|
||||||
func (n *Nameserver) errorf(fmt string, args ...interface{}) {
|
func (n *Nameserver) errorf(fmt string, args ...interface{}) {
|
||||||
Log.Errorf("[nameserver %s] "+fmt, append([]interface{}{n.ourName}, args...)...)
|
n.logf(common.Log.Errorf, fmt, args...)
|
||||||
|
}
|
||||||
|
func (n *Nameserver) logf(f func(string, ...interface{}), fmt string, args ...interface{}) {
|
||||||
|
f("[nameserver %s] "+fmt, append([]interface{}{n.ourName}, args...)...)
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user