diff --git a/CHANGELOG.md b/CHANGELOG.md index 12d49be4c..822087403 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- When it's added the `-v` verbose flag, gitbase will use `debug` as logging level, ignoring any other passed ([#935](https://github.com/src-d/gitbase/pull/935)) + +### Fixed + +- If using docker image, and `info` logging level, it will be now used instead of `debug` ([#935](https://github.com/src-d/gitbase/pull/935)) + + ## [0.24.0-beta1] - 2019-07-08 ### Added diff --git a/cmd/gitbase/command/server.go b/cmd/gitbase/command/server.go index 7da961a43..24e73724f 100644 --- a/cmd/gitbase/command/server.go +++ b/cmd/gitbase/command/server.go @@ -83,8 +83,8 @@ type Server struct { MetricsPort int `long:"metrics-port" env:"GITBASE_METRICS_PORT" default:"2112" description:"Port where the server is going to expose prometheus metrics"` ReadOnly bool `short:"r" long:"readonly" description:"Only allow read queries. This disables creating and deleting indexes as well. Cannot be used with --user-file." env:"GITBASE_READONLY"` SkipGitErrors bool // SkipGitErrors disables failing when Git errors are found. - Verbose bool `short:"v" description:"Activates the verbose mode"` - LogLevel string `long:"log-level" env:"GITBASE_LOG_LEVEL" choice:"info" choice:"debug" choice:"warning" choice:"error" choice:"fatal" default:"info" description:"logging level"` + Verbose bool `short:"v" description:"Activates the verbose mode (equivalent to debug logging level), overwriting any passed logging level"` + LogLevel string `long:"log-level" env:"GITBASE_LOG_LEVEL" choice:"info" choice:"debug" choice:"warning" choice:"error" choice:"fatal" default:"info" description:"logging level; ignored if using -v verbose flag"` } type jaegerLogrus struct { @@ -138,11 +138,18 @@ func (c *Server) Execute(args []string) error { // info is the default log level if c.LogLevel != "info" { - level, err := logrus.ParseLevel(c.LogLevel) - if err != nil { - return fmt.Errorf("cannot parse log level: %s", err.Error()) + if c.Verbose { + logrus.Infof( + "ignoring passed '%s' log-level, using requesed '-v' verbose flag instead", + c.LogLevel, + ) + } else { + level, err := logrus.ParseLevel(c.LogLevel) + if err != nil { + return fmt.Errorf("cannot parse log level: %s", err.Error()) + } + logrus.SetLevel(level) } - logrus.SetLevel(level) } var err error diff --git a/docs/using-gitbase/configuration.md b/docs/using-gitbase/configuration.md index dea584af6..6b7a442b6 100644 --- a/docs/using-gitbase/configuration.md +++ b/docs/using-gitbase/configuration.md @@ -117,6 +117,7 @@ Help Options: -r, --readonly Only allow read queries. This disables creating and deleting indexes as well. Cannot be used with --user-file. [$GITBASE_READONLY] - -v Activates the verbose mode + -v Activates the verbose mode (equivalent to debug + logging level), overwriting any passed logging level --log-level=[info|debug|warning|error|fatal] logging level (default: info) [$GITBASE_LOG_LEVEL] ``` \ No newline at end of file diff --git a/init.sh b/init.sh index 97aa35635..6ddc5594c 100644 --- a/init.sh +++ b/init.sh @@ -10,10 +10,12 @@ user=${GITBASE_USER} password=${GITBASE_PASSWORD} EOT -/tini -s -- /bin/gitbase server -v \ +export GITBASE_LOG_LEVEL=${GITBASE_LOG_LEVEL:-debug} + +/tini -s -- /bin/gitbase server \ --host=0.0.0.0 \ --port=3306 \ --user="$GITBASE_USER" \ --password="$GITBASE_PASSWORD" \ --directories="$GITBASE_REPOS" \ - $SIVA_ARGS \ No newline at end of file + $SIVA_ARGS