From bb3a8ae7aa94d372479e9f521868327793846555 Mon Sep 17 00:00:00 2001 From: zulkhair Date: Wed, 12 Jun 2024 15:59:30 +0700 Subject: [PATCH] re enable debug mode --- cmd/world/cardinal/restart.go | 2 +- cmd/world/cardinal/start.go | 1 + common/logger/init.go | 10 +++++----- common/teacmd/docker.go | 7 ++++--- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/cmd/world/cardinal/restart.go b/cmd/world/cardinal/restart.go index 4f519ed..d3da2b9 100644 --- a/cmd/world/cardinal/restart.go +++ b/cmd/world/cardinal/restart.go @@ -37,7 +37,7 @@ This will restart the following Docker services: if cfg.Debug { err = teacmd.DockerRestart(cfg, []teacmd.DockerService{ teacmd.DockerServiceCardinalDebug, - teacmd.DockerServiceNakama, + teacmd.DockerServiceNakamaDebug, }) } else { err = teacmd.DockerRestart(cfg, []teacmd.DockerService{ diff --git a/cmd/world/cardinal/start.go b/cmd/world/cardinal/start.go index dd0e567..ff55982 100644 --- a/cmd/world/cardinal/start.go +++ b/cmd/world/cardinal/start.go @@ -150,6 +150,7 @@ func init() { startCmd.Flags().Bool(flagBuild, true, "Rebuild Docker images before starting") startCmd.Flags().Bool(flagDetach, false, "Run in detached mode") startCmd.Flags().String(flagLogLevel, "", "Set the log level") + startCmd.Flags().Bool(flagDebug, false, "Enable delve debugging") } // replaceBoolWithFlag overwrites the contents of vale with the contents of the given flag. If the flag diff --git a/common/logger/init.go b/common/logger/init.go index 83e9b9c..c93c147 100644 --- a/common/logger/init.go +++ b/common/logger/init.go @@ -13,9 +13,9 @@ const ( DefaultTimeFormat = "15:04:05.000" DefaultCallerSkipFrameCount = 3 // set to 3 because logger wrapped in logger.go - NoColor = true - UseCaller = false // for developer, if you want to expose line of code of caller - flagDebug = "log-debug" + NoColor = true + UseCaller = false // for developer, if you want to expose line of code of caller + flagLogDebug = "log-debug" ) var ( @@ -65,7 +65,7 @@ func PrintLogs() { // SetDebugMode Allow particular logger/message to be printed // This function will extract flag --log-debug from command func SetDebugMode(cmd *cobra.Command) { - val, err := cmd.Flags().GetBool(flagDebug) + val, err := cmd.Flags().GetBool(flagLogDebug) if err == nil { DebugMode = val } @@ -74,6 +74,6 @@ func SetDebugMode(cmd *cobra.Command) { // AddLogFlag set flag --log-debug func AddLogFlag(cmd ...*cobra.Command) { for _, c := range cmd { - c.Flags().Bool(flagDebug, false, "Enable World CLI debug logs") + c.Flags().Bool(flagLogDebug, false, "Enable World CLI debug logs") } } diff --git a/common/teacmd/docker.go b/common/teacmd/docker.go index 07d5d2c..f8093c6 100644 --- a/common/teacmd/docker.go +++ b/common/teacmd/docker.go @@ -22,6 +22,7 @@ const ( DockerServiceEVM DockerService = "evm" DockerServiceDA DockerService = "celestia-devnet" DockerServiceCardinalDebug DockerService = "cardinal-debug" + DockerServiceNakamaDebug DockerService = "nakama-debug" ) type DockerService string @@ -98,15 +99,14 @@ func DockerStart(cfg *config.Config, services []DockerService) error { // DockerStartAll starts both cardinal and nakama func DockerStartAll(cfg *config.Config) error { services := []DockerService{ - DockerServiceNakama, DockerServiceNakamaDB, DockerServiceRedis, } if cfg.Debug { - services = append(services, DockerServiceCardinalDebug) + services = append(services, DockerServiceCardinalDebug, DockerServiceNakamaDebug) } else { - services = append(services, DockerServiceCardinal) + services = append(services, DockerServiceCardinal, DockerServiceNakama) } return DockerStart(cfg, services) @@ -150,6 +150,7 @@ func DockerStopAll() error { DockerServiceCardinal, DockerServiceCardinalDebug, DockerServiceNakama, + DockerServiceNakamaDebug, DockerServiceNakamaDB, DockerServiceRedis, })