summaryrefslogtreecommitdiffstats
path: root/src/k8splugin/internal/logutils/logger.go
diff options
context:
space:
mode:
authorKiran Kamineni <kiran.k.kamineni@intel.com>2019-11-08 13:01:22 -0800
committerKiran Kamineni <kiran.k.kamineni@intel.com>2019-11-08 13:17:13 -0800
commitd345d6ed10245a042c2cda50b1cf8c90bf366b4b (patch)
treef29a5fe0ac3ebf974c37f10d2474fbdbcfa81aa7 /src/k8splugin/internal/logutils/logger.go
parente3af69fe78abcbb88380ce5d557d93ebd2700ffd (diff)
Update logutils to support multiple fields
Added support for multiple fields and updated instancehandler and app/client.go to use the new functions Issue-ID: MULTICLOUD-577 Change-Id: I7cc04f67e72448aa121d10cfd80d66d544981933 Signed-off-by: Kiran Kamineni <kiran.k.kamineni@intel.com>
Diffstat (limited to 'src/k8splugin/internal/logutils/logger.go')
-rw-r--r--src/k8splugin/internal/logutils/logger.go17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/k8splugin/internal/logutils/logger.go b/src/k8splugin/internal/logutils/logger.go
index 7df23474..2e8f9969 100644
--- a/src/k8splugin/internal/logutils/logger.go
+++ b/src/k8splugin/internal/logutils/logger.go
@@ -4,12 +4,25 @@ import (
log "github.com/sirupsen/logrus"
)
+//Fields is type that will be used by the calling function
+type Fields map[string]interface{}
+
func init() {
// Log as JSON instead of the default ASCII formatter.
log.SetFormatter(&log.JSONFormatter{})
}
-func WithFields(msg string, fkey string, fvalue string) {
- log.WithFields(log.Fields{fkey: fvalue}).Error(msg)
+// Error uses the fields provided and logs
+func Error(msg string, fields Fields) {
+ log.WithFields(log.Fields(fields)).Error(msg)
+}
+
+// Warn uses the fields provided and logs
+func Warn(msg string, fields Fields) {
+ log.WithFields(log.Fields(fields)).Warn(msg)
}
+// Info uses the fields provided and logs
+func Info(msg string, fields Fields) {
+ log.WithFields(log.Fields(fields)).Info(msg)
+}