[VOL-2027] Included instanceId in log message
Change-Id: I83e54640169d9a010ea0a644e8e3ef8ed0663827
diff --git a/internal/pkg/afrouter/affinity-router_test.go b/internal/pkg/afrouter/affinity-router_test.go
index 6dfb969..e78b948 100644
--- a/internal/pkg/afrouter/affinity-router_test.go
+++ b/internal/pkg/afrouter/affinity-router_test.go
@@ -34,7 +34,7 @@
// Unit test initialization
func init() {
// Logger must be configured or bad things happen
- log.SetDefaultLogger(log.JSON, log.DebugLevel, nil)
+ log.SetDefaultLogger(log.JSON, log.DebugLevel, log.Fields{"instanceId": 1})
log.AddPackage(log.JSON, log.WarnLevel, nil)
}
diff --git a/internal/pkg/afrouter/config.go b/internal/pkg/afrouter/config.go
index 6008199..09e1816 100644
--- a/internal/pkg/afrouter/config.go
+++ b/internal/pkg/afrouter/config.go
@@ -29,6 +29,10 @@
"path"
)
+const (
+ default_InstanceID = "arouter001"
+)
+
func ParseCmd() (*Configuration, error) {
config := &Configuration{}
cmdParse := flag.NewFlagSet(path.Base(os.Args[0]), flag.ContinueOnError)
@@ -44,11 +48,19 @@
}
//if(!cmdParse.Parsed()) {
//}
+
+ if val, have := os.LookupEnv("HOSTNAME"); have {
+ config.InstanceID = val
+ } else {
+ config.InstanceID = default_InstanceID
+ }
+
return config, nil
}
// Configuration file loading and parsing
type Configuration struct {
+ InstanceID string
ConfigFile *string
LogLevel *int
GrpcLog *bool
diff --git a/internal/pkg/afrouter/method-router_test.go b/internal/pkg/afrouter/method-router_test.go
index 2214595..47204dd 100644
--- a/internal/pkg/afrouter/method-router_test.go
+++ b/internal/pkg/afrouter/method-router_test.go
@@ -34,7 +34,7 @@
// Unit test initialization
func init() {
// Logger must be configured or bad things happen
- log.SetDefaultLogger(log.JSON, log.DebugLevel, nil)
+ log.SetDefaultLogger(log.JSON, log.DebugLevel, log.Fields{"instanceId": 1})
log.AddPackage(log.JSON, log.WarnLevel, nil)
}
diff --git a/internal/pkg/afrouter/round-robin-router_test.go b/internal/pkg/afrouter/round-robin-router_test.go
index 5d8331e..972832e 100644
--- a/internal/pkg/afrouter/round-robin-router_test.go
+++ b/internal/pkg/afrouter/round-robin-router_test.go
@@ -31,7 +31,7 @@
)
func init() {
- log.SetDefaultLogger(log.JSON, log.DebugLevel, nil)
+ log.SetDefaultLogger(log.JSON, log.DebugLevel, log.Fields{"instanceId": 1})
log.AddPackage(log.JSON, log.WarnLevel, nil)
}
diff --git a/internal/pkg/afrouter/router_test.go b/internal/pkg/afrouter/router_test.go
index 2da77e3..940f6cc 100644
--- a/internal/pkg/afrouter/router_test.go
+++ b/internal/pkg/afrouter/router_test.go
@@ -23,7 +23,7 @@
)
func init() {
- log.SetDefaultLogger(log.JSON, log.DebugLevel, nil)
+ log.SetDefaultLogger(log.JSON, log.DebugLevel, log.Fields{"instanceId": 1})
log.AddPackage(log.JSON, log.WarnLevel, nil)
}
diff --git a/internal/pkg/afrouter/server_test.go b/internal/pkg/afrouter/server_test.go
index f67f8cb..162937c 100644
--- a/internal/pkg/afrouter/server_test.go
+++ b/internal/pkg/afrouter/server_test.go
@@ -24,7 +24,7 @@
)
func init() {
- log.SetDefaultLogger(log.JSON, log.DebugLevel, nil)
+ log.SetDefaultLogger(log.JSON, log.DebugLevel, log.Fields{"instanceId": 1})
log.AddPackage(log.JSON, log.WarnLevel, nil)
}
diff --git a/internal/pkg/afrouter/signals_test.go b/internal/pkg/afrouter/signals_test.go
index 3d72ac4..4033b70 100644
--- a/internal/pkg/afrouter/signals_test.go
+++ b/internal/pkg/afrouter/signals_test.go
@@ -27,7 +27,7 @@
)
func init() {
- log.SetDefaultLogger(log.JSON, log.DebugLevel, nil)
+ log.SetDefaultLogger(log.JSON, log.DebugLevel, log.Fields{"instanceId": 1})
log.AddPackage(log.JSON, log.WarnLevel, nil)
}
diff --git a/internal/pkg/afrouter/source-router_test.go b/internal/pkg/afrouter/source-router_test.go
index 2a9f9d2..b33916c 100644
--- a/internal/pkg/afrouter/source-router_test.go
+++ b/internal/pkg/afrouter/source-router_test.go
@@ -29,7 +29,7 @@
)
func init() {
- log.SetDefaultLogger(log.JSON, log.DebugLevel, nil)
+ log.SetDefaultLogger(log.JSON, log.DebugLevel, log.Fields{"instanceId": 1})
log.AddPackage(log.JSON, log.WarnLevel, nil)
}