summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-01-19 14:57:58 +0300
committerGitHub <[email protected]>2021-01-19 14:57:58 +0300
commit75ebbaac89ce8ebc3ab8de47b16e137844cfcd8a (patch)
treeff51fa5552b897db6e118f3da6771f248efaeaa6
parent8704e833dffd7d41614830b5347ba15fa9f297fd (diff)
parentd34f7defd974918d64c225a535a2d98f3f7294cf (diff)
Merge pull request #486 from spiral/refactor/better_http_debug_logs
refactor(http): Uniform debug message from the http hanlder
-rwxr-xr-xMakefile2
-rw-r--r--cmd/cli/workers.go7
-rw-r--r--plugins/http/plugin.go8
-rw-r--r--tests/plugins/http/http_plugin_test.go2
-rw-r--r--tests/plugins/static/static_plugin_test.go2
5 files changed, 12 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index 706c4e09..acbccd72 100755
--- a/Makefile
+++ b/Makefile
@@ -24,7 +24,6 @@ uninstall: ## Uninstall locally installed RR
rm -f /usr/local/bin/rr
test_coverage:
- go clean -testcache
docker-compose -f tests/docker-compose.yaml up -d
rm -rf coverage
mkdir coverage
@@ -58,7 +57,6 @@ test_coverage:
docker-compose -f tests/docker-compose.yaml down
test: ## Run application tests
- go clean -testcache
docker-compose -f tests/docker-compose.yaml up -d
go test -v -race -cover -tags=debug -covermode=atomic ./utils
go test -v -race -cover -tags=debug -covermode=atomic ./pkg/pipe
diff --git a/cmd/cli/workers.go b/cmd/cli/workers.go
index 03639aa4..47dd2a85 100644
--- a/cmd/cli/workers.go
+++ b/cmd/cli/workers.go
@@ -17,9 +17,8 @@ import (
"github.com/spiral/roadrunner/v2/tools"
)
-var (
- interactive bool
-)
+// use interactive mode
+var interactive bool
const InformerList string = "informer.List"
const InformerWorkers string = "informer.Workers"
@@ -42,7 +41,7 @@ func init() {
root.AddCommand(workersCommand)
}
-func workersHandler(cmd *cobra.Command, args []string) error {
+func workersHandler(_ *cobra.Command, args []string) error {
const op = errors.Op("workers cobra handler")
// get RPC client
client, err := RPCClient()
diff --git a/plugins/http/plugin.go b/plugins/http/plugin.go
index 2e00a91a..f35c321b 100644
--- a/plugins/http/plugin.go
+++ b/plugins/http/plugin.go
@@ -120,7 +120,13 @@ func (s *Plugin) Init(cfg config.Configurer, log logger.Logger, server server.Se
func (s *Plugin) logCallback(event interface{}) {
if ev, ok := event.(ResponseEvent); ok {
- s.log.Debug("http handler response received", "elapsed", ev.Elapsed().String(), "remote address", ev.Request.RemoteAddr)
+ s.log.Debug("",
+ "remote", ev.Request.RemoteAddr,
+ "ts", ev.Elapsed().String(),
+ "resp.status", ev.Response.Status,
+ "method", ev.Request.Method,
+ "uri", ev.Request.URI,
+ )
}
}
diff --git a/tests/plugins/http/http_plugin_test.go b/tests/plugins/http/http_plugin_test.go
index 3aa0f57a..51bf7d0b 100644
--- a/tests/plugins/http/http_plugin_test.go
+++ b/tests/plugins/http/http_plugin_test.go
@@ -1027,7 +1027,7 @@ logs:
mockLogger.EXPECT().Info("worker destructed", "pid", gomock.Any()).MinTimes(1)
mockLogger.EXPECT().Info("worker constructed", "pid", gomock.Any()).MinTimes(1)
- mockLogger.EXPECT().Debug("http handler response received", "elapsed", gomock.Any(), "remote address", "127.0.0.1").MinTimes(1)
+ mockLogger.EXPECT().Debug("", "remote", gomock.Any(), "ts", gomock.Any(), "resp.status", gomock.Any(), "method", gomock.Any(), "uri", gomock.Any()).MinTimes(1)
mockLogger.EXPECT().Info("WORLD", "pid", gomock.Any()).MinTimes(1)
mockLogger.EXPECT().Debug("worker event received", "event", events.EventWorkerLog, "worker state", gomock.Any()).MinTimes(1)
mockLogger.EXPECT().Info(gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes() // placeholder for the workerlogerror
diff --git a/tests/plugins/static/static_plugin_test.go b/tests/plugins/static/static_plugin_test.go
index 74daaa16..a411193d 100644
--- a/tests/plugins/static/static_plugin_test.go
+++ b/tests/plugins/static/static_plugin_test.go
@@ -304,7 +304,7 @@ func TestStaticFilesForbid(t *testing.T) {
mockLogger := mocks.NewMockLogger(controller)
mockLogger.EXPECT().Info("worker constructed", "pid", gomock.Any()).AnyTimes()
- mockLogger.EXPECT().Debug("http handler response received", "elapsed", gomock.Any(), "remote address", "127.0.0.1").AnyTimes()
+ mockLogger.EXPECT().Debug("", "remote", gomock.Any(), "ts", gomock.Any(), "resp.status", gomock.Any(), "method", gomock.Any(), "uri", gomock.Any()).AnyTimes()
mockLogger.EXPECT().Error("file open error", "error", gomock.Any()).AnyTimes()
mockLogger.EXPECT().Info(gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes() // placeholder for the workerlogerror