summaryrefslogtreecommitdiffstats
path: root/src/orchestrator/pkg/infra/logutils
diff options
context:
space:
mode:
authorRitu Sood <ritu.sood@intel.com>2020-01-31 23:29:51 -0800
committerSrivahni Chivukula <srivahni.chivukula@intel.com>2020-02-14 03:54:11 -0800
commita75d489bbf87712371d67dce0753577bdacce0c3 (patch)
treedee646769aa432c814abd86645af612e714640be /src/orchestrator/pkg/infra/logutils
parentc06be6458e9985bd7ac0b25fab03d9c8605f6c4a (diff)
Restructure code and create module library
Restructures and moves code to make it aligned with the current design. https://wiki.onap.org/display/DW/Multi+Cluster+Application+Scheduler examples/example_module.go shows how to import and use modules from this package. Patch#2 Updated example Issue-ID: MULTICLOUD-871 Signed-off-by: Ritu Sood <ritu.sood@intel.com> Change-Id: Ia1e9802a946a07dcca8f79f0e2250933ab3efa66
Diffstat (limited to 'src/orchestrator/pkg/infra/logutils')
-rw-r--r--src/orchestrator/pkg/infra/logutils/logger.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/orchestrator/pkg/infra/logutils/logger.go b/src/orchestrator/pkg/infra/logutils/logger.go
new file mode 100644
index 00000000..2e8f9969
--- /dev/null
+++ b/src/orchestrator/pkg/infra/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)
+}