Skip to content

Commit 7de1eb9

Browse files
committed
Let the user define LOG_LEVEL=info using docker
- 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]>
1 parent 43982f9 commit 7de1eb9

File tree

4 files changed

+28
-9
lines changed

4 files changed

+28
-9
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
### Changed
10+
11+
- When using `-v` verbose flag, will set `debug` as logging level, ignoring any other passed.
12+
13+
### Fixed
14+
15+
- If using docker image, and `info` logging level, it will be now used instead of `debug`.
16+
17+
918
## [0.24.0-beta1] - 2019-07-08
1019

1120
### Added

cmd/gitbase/command/server.go

+13-6
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ type Server struct {
8383
MetricsPort int `long:"metrics-port" env:"GITBASE_METRICS_PORT" default:"2112" description:"Port where the server is going to expose prometheus metrics"`
8484
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"`
8585
SkipGitErrors bool // SkipGitErrors disables failing when Git errors are found.
86-
Verbose bool `short:"v" description:"Activates the verbose mode"`
87-
LogLevel string `long:"log-level" env:"GITBASE_LOG_LEVEL" choice:"info" choice:"debug" choice:"warning" choice:"error" choice:"fatal" default:"info" description:"logging level"`
86+
Verbose bool `short:"v" description:"Activates the verbose mode (equivalent to debug logging level), overwriting any passed logging level"`
87+
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"`
8888
}
8989

9090
type jaegerLogrus struct {
@@ -138,11 +138,18 @@ func (c *Server) Execute(args []string) error {
138138

139139
// info is the default log level
140140
if c.LogLevel != "info" {
141-
level, err := logrus.ParseLevel(c.LogLevel)
142-
if err != nil {
143-
return fmt.Errorf("cannot parse log level: %s", err.Error())
141+
if c.Verbose {
142+
logrus.Infof(
143+
"ignoring passed '%s' log-level, using requesed '-v' verbose flag instead",
144+
c.LogLevel,
145+
)
146+
} else {
147+
level, err := logrus.ParseLevel(c.LogLevel)
148+
if err != nil {
149+
return fmt.Errorf("cannot parse log level: %s", err.Error())
150+
}
151+
logrus.SetLevel(level)
144152
}
145-
logrus.SetLevel(level)
146153
}
147154

148155
var err error

docs/using-gitbase/configuration.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ Help Options:
117117
-r, --readonly Only allow read queries. This disables creating and
118118
deleting indexes as well. Cannot be used with
119119
--user-file. [$GITBASE_READONLY]
120-
-v Activates the verbose mode
120+
-v Activates the verbose mode (equivalent to debug
121+
logging level), overwriting any passed logging level
121122
--log-level=[info|debug|warning|error|fatal] logging level (default: info) [$GITBASE_LOG_LEVEL]
122123
```

init.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ user=${GITBASE_USER}
1010
password=${GITBASE_PASSWORD}
1111
EOT
1212

13-
/tini -s -- /bin/gitbase server -v \
13+
export GITBASE_LOG_LEVEL=${GITBASE_LOG_LEVEL:-debug}
14+
15+
/tini -s -- /bin/gitbase server \
1416
--host=0.0.0.0 \
1517
--port=3306 \
1618
--user="$GITBASE_USER" \
1719
--password="$GITBASE_PASSWORD" \
1820
--directories="$GITBASE_REPOS" \
19-
$SIVA_ARGS
21+
$SIVA_ARGS

0 commit comments

Comments
 (0)