From f97f3a999bd2e1a13f148d59dcb1960ed70c5564 Mon Sep 17 00:00:00 2001 From: rekby Date: Wed, 2 Dec 2020 03:15:45 +0300 Subject: [PATCH] Fixes of request logger --- cmd/a_main-packr.go | 2 +- cmd/config.go | 2 +- cmd/main.go | 2 +- cmd/static/default-config.toml | 4 ++-- internal/proxy/config.go | 4 ++-- internal/proxy/http-proxy.go | 2 ++ internal/proxy/transport_logger.go | 4 ++-- 7 files changed, 11 insertions(+), 9 deletions(-) diff --git a/cmd/a_main-packr.go b/cmd/a_main-packr.go index e0f1e7ae..01879fa4 100644 --- a/cmd/a_main-packr.go +++ b/cmd/a_main-packr.go @@ -7,5 +7,5 @@ import "github.com/gobuffalo/packr" // You can use the "packr clean" command to clean up this, // and any other packr generated files. func init() { - packr.PackJSONBytes("static", "default-config.toml", "\"IyMgQVRURU5USU9OCiMgaXQgaXMgZXhhbXBsZSBmaWxlIG9ubHkuIEl0IGJ1aWx0aW4gaW4gYmluYXJ5IGFuZCBkb24ndCByZWFkIGZyb20gZmlsZSBzeXN0ZW0uCiMgY2hhbmdlcyBpbiBjb25maWdfZGVmYXVsdC50b21sIGhhdmUgbm8gcmVhbCBlZmZlY3QuCgpbR2VuZXJhbF0KCiMgU2Vjb25kcyBmb3IgaXNzdWUgZXZlcnkgY2VydGlmaWNhdGUuIENhbmNlbCBpc3N1ZSBhbmQgcmV0dXJuIGVycm9yIGlmIHRpbWVvdXQuCklzc3VlVGltZW91dCA9IDMwMAoKIyBQYXRoIHRvIGRpciwgd2hpY2ggd2lsbCBzdG9yZSBzdGF0ZSBhbmQgY2VydGlmaWNhdGVzClN0b3JhZ2VEaXIgPSAic3RvcmFnZSIKCiMgU3RvcmUgLmpzb24gaW5mbyB3aXRoIGNlcnRpZmljYXRlIG1ldGFkYXRhIG5lYXIgY2VydGlmaWNhdGUuClN0b3JlSlNPTk1ldGFkYXRhID0gdHJ1ZQoKIyBTdWJkb21haW5zLCBhdXRvLWluY2x1ZGVkIHdpdGhpbiB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zKQ0KVENQQWRkcmVzc2VzID0gWyAiWzo6XTo2MjEwMCIgXQ0KDQojIElQIG5ldHdvcmtzIGZvciBhbGxvdyB0byBnZXQgbWV0cmljcy4NCiMgRGVmYXVsdCAtIGFsbG93IGZyb20gYWxsLg0KIyBFeGFtcGxlOg0KIyBbICIxLjIuMy40LzMyIiwgIjE5Mi4xNjguMC4wLzI0IiwgIjo6MS8xMjgiIF0NCkFsbG93ZWROZXR3b3JrcyA9IFtdDQoNCiMgUGFzc3dvcmQgZm9yIGdldCBtZXRyaWNzLCBhZGQgYXMgZ2V0IHBhcmFtID9wYXNzd29yZD0uLi4NClBhc3N3b3JkICAgICAgICA9ICIiDQoNCiMgQWxsb3cgc2V0IHBhc3N3b3JkIHRvIGVtcHR5IHN0cmluZw0KQWxsb3dFbXB0eVBhc3N3b3JkICA9IGZhbHNlDQoNCg0KDQpbUHJvZmlsZXJdDQpFbmFibGUgPSBmYWxzZQ0KDQojIElQIG5ldHdvcmtzIGZvciBhbGxvdyB0byB1c2UgcHJvZmlsZXIuDQojIERlZmF1bHQgLSBhbGxvdyBmcm9tIGFsbC4NCiMgRXhhbXBsZToNCiMgWyAiMS4yLjMuNC8zMiIsICIxOTIuMTY4LjAuMC8yNCIsICI6OjEvMTI4IiBdDQpBbGxvd2VkTmV0d29ya3MgPSBbXQ0KQmluZEFkZHJlc3MgPSAibG9jYWxob3N0OjMxMzQ0Ig0KUGFzc3dvcmQgICAgICAgID0gIiINCkFsbG93RW1wdHlQYXNzd29yZCAgPSBmYWxzZQ0K\"") } diff --git a/cmd/config.go b/cmd/config.go index e80ea065..5d39e925 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -55,7 +55,7 @@ type logConfig struct { EnableLogToFile bool EnableLogToStdErr bool LogLevel string - DisableAccessLog bool + EnableAccessLog bool EnableRotate bool DeveloperMode bool File string diff --git a/cmd/main.go b/cmd/main.go index 9270ee28..9d2f185e 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -153,7 +153,7 @@ func startProgram(config *configType) { err = tlsListener.Start(ctx, registry) log.DebugFatal(logger, err, "StartAutoRenew tls listener") - config.Proxy.DisableAccessLog = config.Log.DisableAccessLog + config.Proxy.EnableAccessLog = config.Log.EnableAccessLog p := proxy.NewHTTPProxy(ctx, tlsListener) p.GetContext = func(req *http.Request) (i context.Context, e error) { localAddr := req.Context().Value(http.LocalAddrContextKey).(net.Addr) diff --git a/cmd/static/default-config.toml b/cmd/static/default-config.toml index 5995b0a0..10e25372 100644 --- a/cmd/static/default-config.toml +++ b/cmd/static/default-config.toml @@ -41,8 +41,8 @@ EnableLogToStdErr = true # verbose level of log, one of: debug, info, warning, error, fatal LogLevel = "info" -# Disable write info about every http request (but write info about connections if need by level) -DisableAccessLog = false +# Enable write info about every http request (but write info about connections if need by level) +EnableAccessLog = true # Enable self log rotating EnableRotate = true diff --git a/internal/proxy/config.go b/internal/proxy/config.go index a41f7762..c76bcd21 100644 --- a/internal/proxy/config.go +++ b/internal/proxy/config.go @@ -25,7 +25,7 @@ type Config struct { KeepAliveTimeoutSeconds int HTTPSBackend bool HTTPSBackendIgnoreCert bool - DisableAccessLog bool + EnableAccessLog bool } func (c *Config) Apply(ctx context.Context, p *HTTPProxy) error { @@ -47,7 +47,7 @@ func (c *Config) Apply(ctx context.Context, p *HTTPProxy) error { appendDirector(c.getHeadersDirector) appendDirector(c.getSchemaDirector) p.HTTPTransport = Transport{c.HTTPSBackendIgnoreCert} - p.EnableAccessLog = !c.DisableAccessLog + p.EnableAccessLog = c.EnableAccessLog if resErr != nil { zc.L(ctx).Error("Can't parse proxy config", zap.Error(resErr)) diff --git a/internal/proxy/http-proxy.go b/internal/proxy/http-proxy.go index 9775f5ec..5aacaf8a 100644 --- a/internal/proxy/http-proxy.go +++ b/internal/proxy/http-proxy.go @@ -62,12 +62,14 @@ func (p *HTTPProxy) Close() error { // Any public fields must not change after Start called func (p *HTTPProxy) Start() error { if p.HTTPTransport != nil { + p.logger.Info("Set transport to reverse proxy") p.httpReverseProxy.Transport = p.HTTPTransport } if p.EnableAccessLog { p.httpReverseProxy.Transport = NewTransportLogger(p.httpReverseProxy.Transport) } + p.logger.Info("Access log", zap.Bool("enabled", p.EnableAccessLog)) mux := &http.ServeMux{} mux.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) { diff --git a/internal/proxy/transport_logger.go b/internal/proxy/transport_logger.go index 867c32b8..58217607 100644 --- a/internal/proxy/transport_logger.go +++ b/internal/proxy/transport_logger.go @@ -17,11 +17,11 @@ func (t TransportLogger) RoundTrip(request *http.Request) (resp *http.Response, start := time.Now() defer func() { - log.DebugErrorCtx(request.Context(), err, "Request", + log.InfoErrorCtx(request.Context(), err, "Request", zap.Duration("duration_without_body", time.Since(start)), zap.String("initiator_addr", request.RemoteAddr), zap.String("metod", request.Method), - zap.String("host", request.Header.Get("Host")), + zap.String("host", request.Host), zap.String("path", request.URL.Path), zap.String("query", request.URL.RawQuery), zap.Int("status_code", resp.StatusCode),