Skip to content

Commit

Permalink
Merge pull request #321 from yunkon-kim/change-logger-name
Browse files Browse the repository at this point in the history
Change logger names to identify them on Kibana
  • Loading branch information
yunkon-kim authored Aug 17, 2022
2 parents 39c43af + 232a44a commit 092e1fa
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
7 changes: 4 additions & 3 deletions poc-cb-net/cmd/admin-web/admin-web.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions poc-cb-net/cmd/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
Expand All @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions poc-cb-net/cmd/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
Expand All @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions poc-cb-net/cmd/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 092e1fa

Please sign in to comment.