diff --git a/Makefile b/Makefile index a2f8e2c..4b2f124 100644 --- a/Makefile +++ b/Makefile @@ -65,13 +65,16 @@ unset-data: build .PHONY: setup-dependencies setup-dependencies: build get-front get-problem-packages - docker compose up -d postgres redis minio clickhouse - @echo "Wait 2 seconds for db setup" - sleep 2s + @if [ "$(shell docker ps -f status=running | grep -E "postgres|redis|minio|clickhouse" | wc -l)" -eq 4 ]; then \ + echo "Containers already up"; \ + ./bin/clean; \ + else \ + docker compose up -d postgres redis minio clickhouse; \ + @echo "Wait 10 seconds for db setup"; \ + sleep 10s; \ + fi + ./bin/init; -.PHONY: setup-data -setup-data:setup-dependencies unset-data - ./bin/init .PHONY: get-front get-front: @@ -98,7 +101,7 @@ check: gen-proto install-cilint golangci-lint run .PHONY: test -test: build gen-swagger setup-data +test: build gen-swagger setup-dependencies go test -race -covermode=atomic -coverprofile=coverage.out -cover -v -count=1 \ ./models/... ./modules/... ./services/... diff --git a/config.toml b/config.toml index 011b9a6..b2e1608 100644 --- a/config.toml +++ b/config.toml @@ -1,6 +1,6 @@ [log] level = "debug" -force_quote = true +pretty_json = true time_on = true time_format = "2006-01-02 15:04:05" diff --git a/modules/log/log.go b/modules/log/log.go index 8f7c4d8..472987c 100644 --- a/modules/log/log.go +++ b/modules/log/log.go @@ -10,7 +10,7 @@ import ( ) const logLevelProp = "log.level" -const logForceQuote = "log.force_quote" +const logPrettyJson = "log.pretty_json" const logTimeOn = "log.time_on" const logTimeFormat = "log.time_format" @@ -31,8 +31,8 @@ func setupLog() { logrus.SetLevel(logrus.DebugLevel) lvl := config_module.AppConfig().GetString(logLevelProp) - forceQuote := config_module.AppConfig().GetBool(logForceQuote) - fullTimeOn := config_module.AppConfig().GetBool(logTimeOn) + prettyJson := config_module.AppConfig().GetBool(logPrettyJson) + timeOn := config_module.AppConfig().GetBool(logTimeOn) timestampFormat := config_module.AppConfig().GetString(logTimeFormat) logLevel, err := logrus.ParseLevel(lvl) @@ -41,11 +41,10 @@ func setupLog() { logrus.SetLevel(logLevel) } // TODO: control log format in config - // logrus.SetFormatter(&logrus.JSONFormatter{}) - logrus.SetFormatter(&logrus.TextFormatter{ - ForceQuote: forceQuote, // value Quote - FullTimestamp: fullTimeOn, - TimestampFormat: timestampFormat, + logrus.SetFormatter(&logrus.JSONFormatter{ + TimestampFormat: timestampFormat, + DisableTimestamp: !timeOn, + PrettyPrint: prettyJson, }) }