Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let the user define LOG_LEVEL=info using docker #935

Merged
merged 2 commits into from
Jul 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 13 additions & 6 deletions cmd/gitbase/command/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion docs/using-gitbase/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
```
6 changes: 4 additions & 2 deletions init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
$SIVA_ARGS