Add "info" to log level options
@@ -61,12 +61,19 @@ type GlobalFlags struct {
ConfigPath []string
}
+const (
+ logLevelDebug = "debug"
+ logLevelInfo = "info"
+ logLevelError = "error"
+ logLevelNone = "none"
+)
+
var flags = GlobalFlags{
Filter: "",
Format: "",
Save: "",
Host: "",
- Log: "info",
+ Log: logLevelInfo,
Network: "",
ConfigPath: project.DefaultConfigPaths,
}
@@ -110,7 +117,7 @@ func InitFlags(cmd *cobra.Command) {
"log",
"l",
flags.Log,
- "Log level verbosity, values: 'none', 'error', 'debug'",
+ "Log level, options: \"debug\", \"info\", \"error\", \"none\"",
)
cmd.PersistentFlags().StringSliceVarP(
@@ -197,24 +204,26 @@ func resolveHost(proj *project.Project, hostFlag string, networkFlag string) (st
// create logger utility
func createLogger(logFlag string, formatFlag string) output.Logger {
+
// disable logging if we user want a specific format like JSON
// (more common they will not want also to have logs)
+ if formatFlag != "" {
+ logFlag = logLevelNone
+ }
+
var logLevel int
+
switch logFlag {
- case "none":
- logLevel = output.NoneLog
- case "error":
- logLevel = output.ErrorLog
- case "debug":
+ case logLevelDebug:
logLevel = output.DebugLog
+ case logLevelError:
+ logLevel = output.ErrorLog
+ case logLevelNone:
+ logLevel = output.NoneLog
default:
logLevel = output.InfoLog
}
- if formatFlag != "" {
- logLevel = output.NoneLog
- }
-
return output.NewStdoutLogger(logLevel)
}
