diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2020-10-08 12:38:42 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2020-10-13 14:08:30 +0300 |
commit | dc54f4215620da74b70dbd07d0f1369e409d3e0b (patch) | |
tree | 69e26a6cde0b614079a2ab0b361f1efe81a74066 /internal/logging/logging.go | |
parent | 5f461b42e39419795b2669278398a9a7c6ed2cd9 (diff) |
Log serving type used for requestslog-serving-type
This extends our structured logging
with information about how the given
request was served
Diffstat (limited to 'internal/logging/logging.go')
-rw-r--r-- | internal/logging/logging.go | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/internal/logging/logging.go b/internal/logging/logging.go index 3432cdf7..6643e169 100644 --- a/internal/logging/logging.go +++ b/internal/logging/logging.go @@ -53,16 +53,20 @@ func getAccessLogger(format string) (*logrus.Logger, error) { // getExtraLogFields is used to inject additional fields into the // HTTP access logger middleware. func getExtraLogFields(r *http.Request) log.Fields { - var projectID uint64 - if d := request.GetDomain(r); d != nil { - projectID = d.GetProjectID(r) + logFields := log.Fields{ + "pages_https": request.IsHTTPS(r), + "pages_host": request.GetHost(r), } - return log.Fields{ - "pages_https": request.IsHTTPS(r), - "pages_host": request.GetHost(r), - "pages_project_id": projectID, + if d := request.GetDomain(r); d != nil { + if lp := d.GetLookupPath(r); lp != nil { + logFields["pages_project_serving_type"] = lp.ServingType + logFields["pages_project_prefix"] = lp.Prefix + logFields["pages_project_id"] = lp.ProjectID + } } + + return logFields } // BasicAccessLogger configures the GitLab pages basic HTTP access logger middleware |