As we reevaluate how to best support and maintain Staging Ref in the future, we encourage development teams using this environment to highlight their use cases in the following issue: https://gitlab.com/gitlab-com/gl-infra/software-delivery/framework/software-delivery-framework-issue-tracker/-/issues/36.

Skip to content
Snippets Groups Projects
Commit 17cbe0cf authored by Patrick Bajao's avatar Patrick Bajao
Browse files

Merge branch '550-fix-unknown-log-level-message' into 'main'

Default to info level for an empty log-level

Closes #550

See merge request gitlab-org/gitlab-shell!579
parents ede95ae7 384cc476
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -22,6 +22,14 @@ func logFmt(inFmt string) string {
return inFmt
}
func logLevel(inLevel string) string {
if inLevel == "" {
return "info"
}
return inLevel
}
func logFile(inFile string) string {
if inFile == "" {
return "stderr"
Loading
Loading
@@ -35,7 +43,7 @@ func buildOpts(cfg *config.Config) []log.LoggerOption {
log.WithFormatter(logFmt(cfg.LogFormat)),
log.WithOutputName(logFile(cfg.LogFile)),
log.WithTimezone(time.UTC),
log.WithLogLevel(cfg.LogLevel),
log.WithLogLevel(logLevel(cfg.LogLevel)),
}
}
Loading
Loading
Loading
Loading
@@ -30,9 +30,11 @@ func TestConfigure(t *testing.T) {
tmpFile.Close()
data, err := os.ReadFile(tmpFile.Name())
dataStr := string(data)
require.NoError(t, err)
require.Contains(t, string(data), `msg":"this is a test"`)
require.NotContains(t, string(data), `msg:":"debug log message"`)
require.Contains(t, dataStr, `"msg":"this is a test"`)
require.NotContains(t, dataStr, `"msg":"debug log message"`)
require.NotContains(t, dataStr, `"msg":"unknown log level`)
}
func TestConfigureWithDebugLogLevel(t *testing.T) {
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment