Skip to content

Commit

Permalink
Set the default log level in manifests to info.
Browse files Browse the repository at this point in the history
  • Loading branch information
kristofferahl committed Feb 28, 2021
1 parent 0e77451 commit debed74
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/centry/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func handleCommandNotFound(runtime *Runtime, c *cli.Context, command string) {
logger := runtime.context.log.GetLogger()
logger.WithFields(logrus.Fields{
"command": command,
}).Warnf("command not found!")
}).Warnf("command not found")
c.App.Metadata[metadataExitCode] = 127
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/centry/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ OPTIONS:
g.It("should display internal options when hide is set to false", func() {
out := execQuiet("", "test/data/runtime_test_display_internal_options.yaml")
expected := `OPTIONS:
--centry-config-log-level value Overrides the log level
--centry-config-log-level value Overrides the log level (default: "info")
--centry-quiet Disables logging (default: false)`

test.AssertStringContains(g, out.Stdout, expected)
Expand Down
7 changes: 7 additions & 0 deletions internal/pkg/config/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import (
yaml2 "gopkg.in/yaml.v2"
)

const (
defaultLogLevel string = "info"
)

// Manifest defines the structure of a manifest
type Manifest struct {
Scripts []string `yaml:"scripts,omitempty"`
Expand Down Expand Up @@ -117,6 +121,9 @@ func readManifestFile(filename string) ([]byte, error) {
func parseManifestYaml(bs []byte) (*Manifest, error) {
m := Manifest{
Config: Config{
Log: LogConfig{
Level: defaultLogLevel,
},
HideInternalCommands: true,
HideInternalOptions: true,
},
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/log/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func CreateManager(level string, prefix string, io io.InputOutput) *Manager {
func (m *Manager) GetLogger() *logrus.Logger {
if m.logger == nil {
m.logger = logrus.New()
m.logger.Out = m.config.IO.Stderr // TODO: Change to using Stdout
m.logger.Out = m.config.IO.Stderr // TODO: Allow changing to Stdout

l, _ := logrus.ParseLevel(m.config.Level)
m.logger.SetLevel(l)
Expand Down

0 comments on commit debed74

Please sign in to comment.