From 232a44ae541054bb98a05245af9338009e08c5a3 Mon Sep 17 00:00:00 2001 From: Yunkon Kim Date: Wed, 17 Aug 2022 21:36:33 +0900 Subject: [PATCH] Change logger names to identify them on Kibana --- poc-cb-net/cmd/admin-web/admin-web.go | 7 ++++--- poc-cb-net/cmd/agent/agent.go | 7 ++++--- poc-cb-net/cmd/controller/controller.go | 7 ++++--- poc-cb-net/cmd/service/service.go | 7 ++++--- .../cmd/test-client/perf-eval-client/perf-eval-client.go | 7 ++++--- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/poc-cb-net/cmd/admin-web/admin-web.go b/poc-cb-net/cmd/admin-web/admin-web.go index 32b9299..b5fe219 100644 --- a/poc-cb-net/cmd/admin-web/admin-web.go +++ b/poc-cb-net/cmd/admin-web/admin-web.go @@ -36,6 +36,7 @@ import ( // CBLogger represents a logger to show execution processes according to the logging level. var CBLogger *logrus.Logger var config model.Config +var loggerName = "cb-network-admin-web" // gRPC client var cladnetClient pb.CloudAdaptiveNetworkServiceClient @@ -49,7 +50,7 @@ func init() { if env != "" { // Load cb-log config from the environment variable path (default) fmt.Printf("CBLOG_ROOT: %v\n", env) - CBLogger = cblog.GetLogger("cb-network") + CBLogger = cblog.GetLogger(loggerName) } else { // Load cb-log config from the current directory (usually for the production) @@ -63,14 +64,14 @@ func init() { logConfPath := filepath.Join(exePath, "config", "log_conf.yaml") if file.Exists(logConfPath) { fmt.Printf("path of log_conf.yaml: %v\n", logConfPath) - CBLogger = cblog.GetLoggerWithConfigPath("cb-network", logConfPath) + CBLogger = cblog.GetLoggerWithConfigPath(loggerName, logConfPath) } else { // Load cb-log config from the project directory (usually for development) logConfPath = filepath.Join(exePath, "..", "..", "config", "log_conf.yaml") if file.Exists(logConfPath) { fmt.Printf("path of log_conf.yaml: %v\n", logConfPath) - CBLogger = cblog.GetLoggerWithConfigPath("cb-network", logConfPath) + CBLogger = cblog.GetLoggerWithConfigPath(loggerName, logConfPath) } else { err := errors.New("fail to load log_conf.yaml") panic(err) diff --git a/poc-cb-net/cmd/agent/agent.go b/poc-cb-net/cmd/agent/agent.go index 6b4f3ab..2012186 100644 --- a/poc-cb-net/cmd/agent/agent.go +++ b/poc-cb-net/cmd/agent/agent.go @@ -35,6 +35,7 @@ var CBNet *cbnet.CBNetwork // CBLogger represents a logger to show execution processes according to the logging level. var CBLogger *logrus.Logger var config model.Config +var loggerName = "cb-network-agent" func init() { fmt.Println("\nStart......... init() of agent.go") @@ -44,7 +45,7 @@ func init() { if env != "" { // Load cb-log config from the environment variable path (default) fmt.Printf("CBLOG_ROOT: %v\n", env) - CBLogger = cblog.GetLogger("cb-network") + CBLogger = cblog.GetLogger(loggerName) } else { // Load cb-log config from the current directory (usually for the production) @@ -58,14 +59,14 @@ func init() { logConfPath := filepath.Join(exePath, "config", "log_conf.yaml") if file.Exists(logConfPath) { fmt.Printf("path of log_conf.yaml: %v\n", logConfPath) - CBLogger = cblog.GetLoggerWithConfigPath("cb-network", logConfPath) + CBLogger = cblog.GetLoggerWithConfigPath(loggerName, logConfPath) } else { // Load cb-log config from the project directory (usually for development) logConfPath = filepath.Join(exePath, "..", "..", "config", "log_conf.yaml") if file.Exists(logConfPath) { fmt.Printf("path of log_conf.yaml: %v\n", logConfPath) - CBLogger = cblog.GetLoggerWithConfigPath("cb-network", logConfPath) + CBLogger = cblog.GetLoggerWithConfigPath(loggerName, logConfPath) } else { err := errors.New("fail to load log_conf.yaml") panic(err) diff --git a/poc-cb-net/cmd/controller/controller.go b/poc-cb-net/cmd/controller/controller.go index 4a8b562..f5a4c22 100644 --- a/poc-cb-net/cmd/controller/controller.go +++ b/poc-cb-net/cmd/controller/controller.go @@ -28,6 +28,7 @@ import ( // CBLogger represents a logger to show execution processes according to the logging level. var CBLogger *logrus.Logger var config model.Config +var loggerName = "cb-network-controller" func init() { fmt.Println("\nStart......... init() of controller.go") @@ -37,7 +38,7 @@ func init() { if env != "" { // Load cb-log config from the environment variable path (default) fmt.Printf("CBLOG_ROOT: %v\n", env) - CBLogger = cblog.GetLogger("cb-network") + CBLogger = cblog.GetLogger(loggerName) } else { // Load cb-log config from the current directory (usually for the production) @@ -51,14 +52,14 @@ func init() { logConfPath := filepath.Join(exePath, "config", "log_conf.yaml") if file.Exists(logConfPath) { fmt.Printf("path of log_conf.yaml: %v\n", logConfPath) - CBLogger = cblog.GetLoggerWithConfigPath("cb-network", logConfPath) + CBLogger = cblog.GetLoggerWithConfigPath(loggerName, logConfPath) } else { // Load cb-log config from the project directory (usually for development) logConfPath = filepath.Join(exePath, "..", "..", "config", "log_conf.yaml") if file.Exists(logConfPath) { fmt.Printf("path of log_conf.yaml: %v\n", logConfPath) - CBLogger = cblog.GetLoggerWithConfigPath("cb-network", logConfPath) + CBLogger = cblog.GetLoggerWithConfigPath(loggerName, logConfPath) } else { err := errors.New("fail to load log_conf.yaml") panic(err) diff --git a/poc-cb-net/cmd/service/service.go b/poc-cb-net/cmd/service/service.go index a611dfa..8a5f63c 100644 --- a/poc-cb-net/cmd/service/service.go +++ b/poc-cb-net/cmd/service/service.go @@ -46,6 +46,7 @@ import ( var CBLogger *logrus.Logger var config model.Config var etcdClient *clientv3.Client +var loggerName = "cb-network-service" func init() { fmt.Println("\nStart......... init() of cb-network service.go") @@ -55,7 +56,7 @@ func init() { if env != "" { // Load cb-log config from the environment variable path (default) fmt.Printf("CBLOG_ROOT: %v\n", env) - CBLogger = cblog.GetLogger("cb-network") + CBLogger = cblog.GetLogger(loggerName) } else { // Load cb-log config from the current directory (usually for the production) @@ -69,14 +70,14 @@ func init() { logConfPath := filepath.Join(exePath, "config", "log_conf.yaml") if file.Exists(logConfPath) { fmt.Printf("path of log_conf.yaml: %v\n", logConfPath) - CBLogger = cblog.GetLoggerWithConfigPath("cb-network", logConfPath) + CBLogger = cblog.GetLoggerWithConfigPath(loggerName, logConfPath) } else { // Load cb-log config from the project directory (usually for development) logConfPath = filepath.Join(exePath, "..", "..", "config", "log_conf.yaml") if file.Exists(logConfPath) { fmt.Printf("path of log_conf.yaml: %v\n", logConfPath) - CBLogger = cblog.GetLoggerWithConfigPath("cb-network", logConfPath) + CBLogger = cblog.GetLoggerWithConfigPath(loggerName, logConfPath) } else { err := errors.New("fail to load log_conf.yaml") panic(err) diff --git a/poc-cb-net/cmd/test-client/perf-eval-client/perf-eval-client.go b/poc-cb-net/cmd/test-client/perf-eval-client/perf-eval-client.go index 57c917e..89d449d 100644 --- a/poc-cb-net/cmd/test-client/perf-eval-client/perf-eval-client.go +++ b/poc-cb-net/cmd/test-client/perf-eval-client/perf-eval-client.go @@ -49,6 +49,7 @@ const ( // CBLogger represents a logger to show execution processes according to the logging level. var CBLogger *logrus.Logger +var loggerName="perf-eval-client" // CB-Tumblebug var endpointTB = "localhost:1323" @@ -81,7 +82,7 @@ func init() { if env != "" { // Load cb-log config from the environment variable path (default) fmt.Printf("CBLOG_ROOT: %v\n", env) - CBLogger = cblog.GetLogger("cb-network") + CBLogger = cblog.GetLogger(loggerName) } else { // Load cb-log config from the current directory (usually for the production) @@ -95,14 +96,14 @@ func init() { logConfPath := filepath.Join(exePath, "config", "log_conf.yaml") if file.Exists(logConfPath) { fmt.Printf("path of log_conf.yaml: %v\n", logConfPath) - CBLogger = cblog.GetLoggerWithConfigPath("cb-network", logConfPath) + CBLogger = cblog.GetLoggerWithConfigPath(loggerName, logConfPath) } else { // Load cb-log config from the project directory (usually for development) logConfPath = filepath.Join(exePath, "..", "..", "..", "config", "log_conf.yaml") if file.Exists(logConfPath) { fmt.Printf("path of log_conf.yaml: %v\n", logConfPath) - CBLogger = cblog.GetLoggerWithConfigPath("cb-network", logConfPath) + CBLogger = cblog.GetLoggerWithConfigPath(loggerName, logConfPath) } else { err := errors.New("fail to load log_conf.yaml") panic(err)