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

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <git@zjvandeweg.nl>2018-04-25 18:25:16 +0300
committerZeger-Jan van de Weg <git@zjvandeweg.nl>2018-04-26 14:44:28 +0300
commit90db3e5add7ee93e3b88633cad01371442a0e733 (patch)
treee93d4881ac371e61af1a0e173a4f49f43d475427
parent221364d0506d9bad9705dcb10c34deb9a7e69c79 (diff)
Allow configuration of log levels
Log level cannot be set for Gitaly, which makes it very verbose in production. This is not a problem, but in a development environment it might be. Especially when other applications log to STDOUT too, details get lost. Closes https://gitlab.com/gitlab-org/gitaly/issues/1156
-rw-r--r--CHANGELOG.md2
-rw-r--r--config.toml.example10
-rw-r--r--doc/configuration/README.md1
-rw-r--r--internal/config/config.go1
-rw-r--r--internal/config/logger.go9
5 files changed, 18 insertions, 5 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a980fed2c..08405cfab 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,8 @@
UNRELEASED
+- Allow configuration of the log level in `config.toml`
+ https://gitlab.com/gitlab-org/gitaly/merge_requests/696
- Copy Gitlab::Git::Repository#exists? implementation for internal method calls
https://gitlab.com/gitlab-org/gitaly/merge_requests/693
- Upgrade Licensee gem to match the CE gem
diff --git a/config.toml.example b/config.toml.example
index 76b708c1a..b47ce94eb 100644
--- a/config.toml.example
+++ b/config.toml.example
@@ -11,7 +11,6 @@ bin_dir = "/home/git/gitaly"
# # Optional: export metrics via Prometheus
# prometheus_listen_addr = "localhost:9236"
-#
# # Git executable settings
# [git]
@@ -31,6 +30,11 @@ path = "/home/git/repositories"
# # You can optionally configure Gitaly to output JSON-formatted log messages to stdout
# [logging]
# format = "json"
+# # Optional: Set log level to only log entries with that severity or above
+# # One of, in order: debug, info, warn, errror, fatal, panic
+# # Defaults to "info"
+# level = "warn"
+#
# # Additionally exceptions from the Go server can be reported to Sentry
# sentry_dsn = "https://<key>:<secret>@sentry.io/<project>"
# # Exceptions from gitaly-ruby can also be reported to Sentry
@@ -46,10 +50,10 @@ dir = "/home/git/gitaly/ruby"
# # Gitaly-ruby resident set size (RSS) that triggers a memory restart (bytes)
# max_rss = 300000000
-#
+#
# # Grace period before a gitaly-ruby process is forcibly terminated after exceeding max_rss (seconds)
# graceful_restart_timeout = "10m"
-#
+#
# # Time that gitaly-ruby memory must remain high before a restart (seconds)
# restart_delay = "5m"
diff --git a/doc/configuration/README.md b/doc/configuration/README.md
index e7778f6ba..88ac51b1e 100644
--- a/doc/configuration/README.md
+++ b/doc/configuration/README.md
@@ -118,6 +118,7 @@ max\_rss limit.
|name|type|required|notes|
|----|----|--------|-----|
|format|string|no|Log format: "text" or "json". Default: "text"|
+|level|string|no| Log level: "debug", "info", "warn", "error", "fatal", or "panic". Default: "info"|
|sentry_dsn|string|no|Sentry DSN for exception monitoring|
|ruby_sentry_dsn|string|no|Sentry DSN for gitaly-ruby exception monitoring|
diff --git a/internal/config/config.go b/internal/config/config.go
index ae9c156d7..fe24aab8c 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -54,6 +54,7 @@ type Logging struct {
Format string
SentryDSN string `toml:"sentry_dsn"`
RubySentryDSN string `toml:"ruby_sentry_dsn"`
+ Level string `toml:"level"`
}
// Prometheus contains additional configuration data for prometheus
diff --git a/internal/config/logger.go b/internal/config/logger.go
index 65a6127d8..e66a28845 100644
--- a/internal/config/logger.go
+++ b/internal/config/logger.go
@@ -32,10 +32,15 @@ func configureLoggingFormat() {
// ConfigureLogging uses the global conf and environmental vars to configure the logged
func ConfigureLogging() {
+ if level, err := log.ParseLevel(Config.Logging.Level); err != nil {
+ log.SetLevel(log.InfoLevel)
+ } else {
+ log.SetLevel(level)
+ }
+
+ // Allow override based on environment variable
if debugLoggingEnabled {
log.SetLevel(log.DebugLevel)
- } else {
- log.SetLevel(log.InfoLevel)
}
configureLoggingFormat()