summaryrefslogtreecommitdiffstats
path: root/src/orchestrator/internal/logutils/logger.go
diff options
context:
space:
mode:
authorRitu Sood <Ritu.Sood@intel.com>2020-01-03 15:06:17 +0000
committerGerrit Code Review <gerrit@onap.org>2020-01-03 15:06:17 +0000
commit133ab2099e0846590bfcb564bf0d818dbfa33b37 (patch)
tree7e34e854b28f110d70f0c0ada3f5ff215b6b8c0a /src/orchestrator/internal/logutils/logger.go
parent0bb568df3002446f9fdeb3da587dcec76c5c5fcc (diff)
parent5b21b7900406573bdde42afdac1acd8fc1b9dc07 (diff)
Merge "Adding logging package to v2"
Diffstat (limited to 'src/orchestrator/internal/logutils/logger.go')
-rw-r--r--src/orchestrator/internal/logutils/logger.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/orchestrator/internal/logutils/logger.go b/src/orchestrator/internal/logutils/logger.go
new file mode 100644
index 00000000..2e8f9969
--- /dev/null
+++ b/src/orchestrator/internal/logutils/logger.go
@@ -0,0 +1,28 @@
+package logutils
+
+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{})
+}
+
+// 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)
+}