use zap for logging (#1112)

Use zap for logging
This commit is contained in:
Jon Carl
2019-03-14 21:11:15 +05:30
committed by Vishal
parent c717f182b6
commit 0fc864f230
98 changed files with 2031 additions and 1223 deletions
+7 -5
View File
@@ -17,10 +17,10 @@ limitations under the License.
package router
import (
"log"
"net/url"
"time"
"go.uber.org/zap"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/fission/fission/cache"
@@ -28,7 +28,8 @@ import (
type (
functionServiceMap struct {
cache *cache.Cache // map[metadataKey]*url.URL
logger *zap.Logger
cache *cache.Cache // map[metadataKey]*url.URL
}
// metav1.ObjectMeta is not hashable, so we make a hashable copy
@@ -40,9 +41,10 @@ type (
}
)
func makeFunctionServiceMap(expiry time.Duration) *functionServiceMap {
func makeFunctionServiceMap(logger *zap.Logger, expiry time.Duration) *functionServiceMap {
return &functionServiceMap{
cache: cache.MakeCache(expiry, 0),
logger: logger.Named("function_service_map"),
cache: cache.MakeCache(expiry, 0),
}
}
@@ -71,7 +73,7 @@ func (fmap *functionServiceMap) assign(f *metav1.ObjectMeta, serviceUrl *url.URL
if *serviceUrl == *(old.(*url.URL)) {
return
}
log.Printf("error caching service url for function with a different value: %v", err)
fmap.logger.Error("error caching service url for function with a different value", zap.Error(err))
// ignore error
}
}