diff options
author | Jacob Vosmaer (GitLab) <jacob@gitlab.com> | 2018-04-26 20:17:54 +0300 |
---|---|---|
committer | Jacob Vosmaer (GitLab) <jacob@gitlab.com> | 2018-04-26 20:17:54 +0300 |
commit | 91659758bbc621449dbd3fa222c5cffcc5d0e171 (patch) | |
tree | e93d4881ac371e61af1a0e173a4f49f43d475427 | |
parent | 221364d0506d9bad9705dcb10c34deb9a7e69c79 (diff) | |
parent | 90db3e5add7ee93e3b88633cad01371442a0e733 (diff) |
Merge branch 'zj-log-level-config' into 'master'
Allow configuration of log levels
Closes #1156
See merge request gitlab-org/gitaly!696
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | config.toml.example | 10 | ||||
-rw-r--r-- | doc/configuration/README.md | 1 | ||||
-rw-r--r-- | internal/config/config.go | 1 | ||||
-rw-r--r-- | internal/config/logger.go | 9 |
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() |