diff --git a/go.mod b/go.mod index 0513c25..1fe7dda 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.16 require ( github.com/BurntSushi/toml v0.3.1 // indirect github.com/go-pkgz/lgr v0.10.4 - github.com/go-pkgz/rest v1.9.1 + github.com/go-pkgz/rest v1.9.2 github.com/gorilla/handlers v1.5.1 github.com/stretchr/testify v1.7.0 github.com/umputun/go-flags v1.5.1 diff --git a/go.sum b/go.sum index c020179..6b8d66d 100644 --- a/go.sum +++ b/go.sum @@ -8,6 +8,8 @@ github.com/go-pkgz/lgr v0.10.4 h1:l7qyFjqEZgwRgaQQSEp6tve4A3OU80VrfzpvtEX8ngw= github.com/go-pkgz/lgr v0.10.4/go.mod h1:CD0s1z6EFpIUplV067gitF77tn25JItzwHNKAPqeCF0= github.com/go-pkgz/rest v1.9.1 h1:JW876BgJJ/MOkAYRnnzpfX7xUqIav+ou1LSVTtQq/Lo= github.com/go-pkgz/rest v1.9.1/go.mod h1:wZ/dGipZUaF9to0vIQl7PwDHgWQDB0jsrFg1xnAKLDw= +github.com/go-pkgz/rest v1.9.2 h1:RyBBRXBYY6eBgTW3UGYOyT4VQPDiBBFh/tesELWsryQ= +github.com/go-pkgz/rest v1.9.2/go.mod h1:wZ/dGipZUaF9to0vIQl7PwDHgWQDB0jsrFg1xnAKLDw= github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4= github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= diff --git a/vendor/github.com/go-pkgz/rest/logger/logger.go b/vendor/github.com/go-pkgz/rest/logger/logger.go index 0efbd9a..a95d592 100644 --- a/vendor/github.com/go-pkgz/rest/logger/logger.go +++ b/vendor/github.com/go-pkgz/rest/logger/logger.go @@ -41,6 +41,7 @@ type logParts struct { remoteIP string statusCode int respSize int + host string prefix string user string @@ -108,10 +109,16 @@ func (l *Middleware) Handler(next http.Handler) http.Handler { remoteIP = l.ipFn(remoteIP) } + server := r.URL.Hostname() + if server == "" { + server = strings.Split(r.Host, ":")[0] + } + p := &logParts{ duration: t2.Sub(t1), rawURL: rawurl, method: r.Method, + host: server, remoteIP: remoteIP, statusCode: ww.status, respSize: ww.size, @@ -135,8 +142,8 @@ func (l *Middleware) formatDefault(r *http.Request, p *logParts) string { _, _ = bld.WriteString(" ") } - _, _ = bld.WriteString(fmt.Sprintf("%s - %s - %s - %d (%d) - %v", - p.method, p.rawURL, p.remoteIP, p.statusCode, p.respSize, p.duration)) + _, _ = bld.WriteString(fmt.Sprintf("%s - %s - %s - %s - %d (%d) - %v", + p.method, p.rawURL, p.host, p.remoteIP, p.statusCode, p.respSize, p.duration)) if p.user != "" { _, _ = bld.WriteString(" - ") diff --git a/vendor/modules.txt b/vendor/modules.txt index b554a01..e28187e 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -7,7 +7,7 @@ github.com/felixge/httpsnoop # github.com/go-pkgz/lgr v0.10.4 ## explicit github.com/go-pkgz/lgr -# github.com/go-pkgz/rest v1.9.1 +# github.com/go-pkgz/rest v1.9.2 ## explicit github.com/go-pkgz/rest github.com/go-pkgz/rest/logger