Skip to content

Commit

Permalink
Let the user define LOG_LEVEL=info using docker
Browse files Browse the repository at this point in the history
- docker entrypoint should not force the usage of 'verbose' mode
- docker entrypoint uses 'debug' log level as default if not defined
- verbose flag will override any other passed log level, not only 'info'

Signed-off-by: David Pordomingo <[email protected]>
  • Loading branch information
dpordomingo committed Jul 19, 2019
1 parent 43982f9 commit 7de1eb9
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
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 using `-v` verbose flag, will set `debug` as logging level, ignoring any other passed.

### Fixed

- If using docker image, and `info` logging level, it will be now used instead of `debug`.


## [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

0 comments on commit 7de1eb9

Please sign in to comment.