Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Shushlin <vshushlin@gitlab.com>2021-06-17 11:49:54 +0300
committerVladimir Shushlin <vshushlin@gitlab.com>2021-06-17 11:49:54 +0300
commit569d73d925857629c49ed824df5ee1afdf95af76 (patch)
tree49bf05b3444c9dcb319ffab822cf7d95fd262319
parent39c7efd7a9045cfde6ca230e5586d8ae1842ddb0 (diff)
parent26b1dce3b5ad1e58643462d8be9bebd17429cb5e (diff)
Merge branch 'default/json-logging' into 'master'
Default to JSON Logging Closes #223 See merge request gitlab-org/gitlab-pages!489
-rw-r--r--internal/config/flags.go2
-rw-r--r--internal/logging/logging.go2
-rw-r--r--test/acceptance/proxyv2_test.go8
3 files changed, 7 insertions, 5 deletions
diff --git a/internal/config/flags.go b/internal/config/flags.go
index fcbc6368..6617a1ee 100644
--- a/internal/config/flags.go
+++ b/internal/config/flags.go
@@ -25,7 +25,7 @@ var (
daemonGID = flag.Uint("daemon-gid", 0, "Drop privileges to this group")
daemonInplaceChroot = flag.Bool("daemon-inplace-chroot", false, "Fall back to a non-bind-mount chroot of -pages-root when daemonizing")
propagateCorrelationID = flag.Bool("propagate-correlation-id", false, "Reuse existing Correlation-ID from the incoming request header `X-Request-ID` if present")
- logFormat = flag.String("log-format", "text", "The log output format: 'text' or 'json'")
+ logFormat = flag.String("log-format", "json", "The log output format: 'text' or 'json'")
logVerbose = flag.Bool("log-verbose", false, "Verbose logging")
secret = flag.String("auth-secret", "", "Cookie store hash key, should be at least 32 bytes long")
gitLabServer = flag.String("gitlab-server", "", "GitLab server, for example https://www.gitlab.com")
diff --git a/internal/logging/logging.go b/internal/logging/logging.go
index 769856a2..10705a9a 100644
--- a/internal/logging/logging.go
+++ b/internal/logging/logging.go
@@ -16,7 +16,7 @@ func ConfigureLogging(format string, verbose bool) error {
var levelOption log.LoggerOption
if format == "" {
- format = "text"
+ format = "json"
}
if verbose {
diff --git a/test/acceptance/proxyv2_test.go b/test/acceptance/proxyv2_test.go
index 670f711c..095007ba 100644
--- a/test/acceptance/proxyv2_test.go
+++ b/test/acceptance/proxyv2_test.go
@@ -21,14 +21,14 @@ func TestProxyv2(t *testing.T) {
urlSuffix string
expectedStatusCode int
expectedContent string
- expectedLog string
+ expectedLog []string
}{
"basic_proxyv2_request": {
host: "group.gitlab-example.com",
urlSuffix: "project/",
expectedStatusCode: http.StatusOK,
expectedContent: "project-subdir\n",
- expectedLog: "group.gitlab-example.com 10.1.1.1",
+ expectedLog: []string{"\"host\":\"group.gitlab-example.com\"", "\"remote_ip\":\"10.1.1.1\""},
},
}
@@ -49,7 +49,9 @@ func TestProxyv2(t *testing.T) {
// give the process enough time to write the log message
require.Eventually(t, func() bool {
- require.Contains(t, logBuf.String(), tt.expectedLog, "log mismatch")
+ for _, e := range tt.expectedLog {
+ require.Contains(t, logBuf.String(), e, "log mismatch")
+ }
return true
}, time.Second, time.Millisecond)
})