diff --git a/config.dev.toml b/config.dev.toml index 187eeb37d..16f11779c 100755 --- a/config.dev.toml +++ b/config.dev.toml @@ -81,7 +81,7 @@ LogLevel = "debug" # LogFormat determines the format that logs are output in. Defaults to json. # It is only used when CloudRuntime is set to none. Values can be "plain" or "json". # Env override: ATHENS_LOG_FORMAT -LogFormat = "json" +LogFormat = "plain" # CloudRuntime is the Cloud Provider on which the Proxy/Registry is running. # Currently available options are "GCP", or "none". Defaults to "none" diff --git a/pkg/config/config.go b/pkg/config/config.go index 177a0b523..35aaccc1d 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -151,7 +151,7 @@ func defaultConfig() *Config { GoGetWorkers: 10, ProtocolWorkers: 30, LogLevel: "debug", - LogFormat: "json", + LogFormat: "plain", CloudRuntime: "none", EnablePprof: false, PprofPort: ":3001", diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index fe3a7425f..e10a2afbe 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -258,7 +258,7 @@ func TestParseExampleConfig(t *testing.T) { expConf := &Config{ GoEnv: "development", LogLevel: "debug", - LogFormat: "json", + LogFormat: "plain", GoBinary: "go", GoGetWorkers: 10, ProtocolWorkers: 30, diff --git a/pkg/log/log_test.go b/pkg/log/log_test.go index f2d4a9b6b..2639c7a12 100644 --- a/pkg/log/log_test.go +++ b/pkg/log/log_test.go @@ -97,6 +97,18 @@ var testCases = []input{ }, { name: "default", + cloudProvider: "none", + level: logrus.DebugLevel, + fields: logrus.Fields{"xyz": "abc", "abc": "xyz"}, + logFunc: func(e Entry) time.Time { + t := time.Now() + e.Warnf("warn message") + return t + }, + output: `WARNING[%v]: warn message` + "\t" + `abc=xyz xyz=abc` + " \n", + }, + { + name: "default json", format: "json", cloudProvider: "none", level: logrus.DebugLevel, @@ -121,7 +133,7 @@ func TestCloudLogger(t *testing.T) { out := buf.String() expected := tc.output if strings.Contains(expected, "%v") { - if tc.format == "plain" { + if tc.format == "plain" || (tc.format == "" && (tc.cloudProvider == "none" || tc.cloudProvider == "")) { expected = fmt.Sprintf(expected, entryTime.Format(time.Kitchen)) } else { expected = fmt.Sprintf(expected, entryTime.Format(time.RFC3339))