tweak ipam plugin logging
- log requests at info level instead of debug level - log errors at error level instead of debug level
This commit is contained in:
1 parent
5aa2a7a14c
commit
4482d307bf
1 file changed
+9
-5
@@ -26,7 +26,7 @@ func (i *Ipam) GetDefaultAddressSpaces() (string, string, error) {
|
|||||||
|
|
||||||
func (i *Ipam) RequestPool(addressSpace, pool, subPool string, options map[string]string, v6 bool) (poolname string, subnet *net.IPNet, data map[string]string, err error) {
|
func (i *Ipam) RequestPool(addressSpace, pool, subPool string, options map[string]string, v6 bool) (poolname string, subnet *net.IPNet, data map[string]string, err error) {
|
||||||
i.logReq("RequestPool", addressSpace, pool, subPool, options)
|
i.logReq("RequestPool", addressSpace, pool, subPool, options)
|
||||||
defer func() { i.logRes("RequestPool", poolname, subnet, data, err) }()
|
defer func() { i.logRes("RequestPool", err, poolname, subnet, data) }()
|
||||||
if pool == "" {
|
if pool == "" {
|
||||||
subnet, err = i.weave.DefaultSubnet()
|
subnet, err = i.weave.DefaultSubnet()
|
||||||
} else {
|
} else {
|
||||||
@@ -56,7 +56,7 @@ func (i *Ipam) ReleasePool(poolID string) error {
|
|||||||
|
|
||||||
func (i *Ipam) RequestAddress(poolID string, address net.IP, options map[string]string) (ip *net.IPNet, _ map[string]string, err error) {
|
func (i *Ipam) RequestAddress(poolID string, address net.IP, options map[string]string) (ip *net.IPNet, _ map[string]string, err error) {
|
||||||
i.logReq("RequestAddress", poolID, address, options)
|
i.logReq("RequestAddress", poolID, address, options)
|
||||||
defer func() { i.logRes("RequestAddress", ip, err) }()
|
defer func() { i.logRes("RequestAddress", err, ip) }()
|
||||||
// If we pass magic string "_" to weave IPAM it stores the address under its own string
|
// If we pass magic string "_" to weave IPAM it stores the address under its own string
|
||||||
if poolID == "weavepool" { // old-style
|
if poolID == "weavepool" { // old-style
|
||||||
ip, err = i.weave.AllocateIP("_")
|
ip, err = i.weave.AllocateIP("_")
|
||||||
@@ -107,9 +107,13 @@ func (i *Ipam) DiscoverDelete(discoverapi.DiscoveryType, interface{}) error {
|
|||||||
// logging
|
// logging
|
||||||
|
|
||||||
func (i *Ipam) logReq(fun string, args ...interface{}) {
|
func (i *Ipam) logReq(fun string, args ...interface{}) {
|
||||||
common.Log.Debugln(append([]interface{}{fmt.Sprintf("[ipam] %s", fun)}, args...)...)
|
common.Log.Infoln(append([]interface{}{fmt.Sprintf("[ipam] %s", fun)}, args...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Ipam) logRes(fun string, args ...interface{}) {
|
func (i *Ipam) logRes(fun string, err error, args ...interface{}) {
|
||||||
common.Log.Debugln(append([]interface{}{fmt.Sprintf("[ipam] %s result", fun)}, args...)...)
|
if err == nil {
|
||||||
|
common.Log.Debugln(append([]interface{}{fmt.Sprintf("[ipam] %s result", fun)}, args...)...)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
common.Log.Errorf("[ipam] %s: %s", fun, err)
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user