Implement "crowdsec -fatal" flag; change help message (#2266)
The -trace...-fatal flags do not change the log destination but only the verbosity. This change reflects that, and implements "-fatal" which was missing.
This commit is contained in:
parent
8da9d5eefd
commit
4e2c9c185b
|
@ -52,11 +52,14 @@ var (
|
||||||
|
|
||||||
type Flags struct {
|
type Flags struct {
|
||||||
ConfigFile string
|
ConfigFile string
|
||||||
TraceLevel bool
|
|
||||||
DebugLevel bool
|
LogLevelTrace bool
|
||||||
InfoLevel bool
|
LogLevelDebug bool
|
||||||
WarnLevel bool
|
LogLevelInfo bool
|
||||||
ErrorLevel bool
|
LogLevelWarn bool
|
||||||
|
LogLevelError bool
|
||||||
|
LogLevelFatal bool
|
||||||
|
|
||||||
PrintVersion bool
|
PrintVersion bool
|
||||||
SingleFileType string
|
SingleFileType string
|
||||||
Labels map[string]string
|
Labels map[string]string
|
||||||
|
@ -140,11 +143,14 @@ func (l labelsMap) Set(label string) error {
|
||||||
|
|
||||||
func (f *Flags) Parse() {
|
func (f *Flags) Parse() {
|
||||||
flag.StringVar(&f.ConfigFile, "c", csconfig.DefaultConfigPath("config.yaml"), "configuration file")
|
flag.StringVar(&f.ConfigFile, "c", csconfig.DefaultConfigPath("config.yaml"), "configuration file")
|
||||||
flag.BoolVar(&f.TraceLevel, "trace", false, "VERY verbose")
|
|
||||||
flag.BoolVar(&f.DebugLevel, "debug", false, "print debug-level on stderr")
|
flag.BoolVar(&f.LogLevelTrace, "trace", false, "set log level to 'trace' (VERY verbose)")
|
||||||
flag.BoolVar(&f.InfoLevel, "info", false, "print info-level on stderr")
|
flag.BoolVar(&f.LogLevelDebug, "debug", false, "set log level to 'debug'")
|
||||||
flag.BoolVar(&f.WarnLevel, "warning", false, "print warning-level on stderr")
|
flag.BoolVar(&f.LogLevelInfo, "info", false, "set log level to 'info'")
|
||||||
flag.BoolVar(&f.ErrorLevel, "error", false, "print error-level on stderr")
|
flag.BoolVar(&f.LogLevelWarn, "warning", false, "set log level to 'warning'")
|
||||||
|
flag.BoolVar(&f.LogLevelError, "error", false, "set log level to 'error'")
|
||||||
|
flag.BoolVar(&f.LogLevelFatal, "fatal", false, "set log level to 'fatal'")
|
||||||
|
|
||||||
flag.BoolVar(&f.PrintVersion, "version", false, "display version")
|
flag.BoolVar(&f.PrintVersion, "version", false, "display version")
|
||||||
flag.StringVar(&f.OneShotDSN, "dsn", "", "Process a single data source in time-machine")
|
flag.StringVar(&f.OneShotDSN, "dsn", "", "Process a single data source in time-machine")
|
||||||
flag.StringVar(&f.Transform, "transform", "", "expr to apply on the event after acquisition")
|
flag.StringVar(&f.Transform, "transform", "", "expr to apply on the event after acquisition")
|
||||||
|
@ -172,16 +178,18 @@ func newLogLevel(curLevelPtr *log.Level, f *Flags) *log.Level {
|
||||||
|
|
||||||
// override from flags
|
// override from flags
|
||||||
switch {
|
switch {
|
||||||
case f.TraceLevel:
|
case f.LogLevelTrace:
|
||||||
ret = log.TraceLevel
|
ret = log.TraceLevel
|
||||||
case f.DebugLevel:
|
case f.LogLevelDebug:
|
||||||
ret = log.DebugLevel
|
ret = log.DebugLevel
|
||||||
case f.InfoLevel:
|
case f.LogLevelInfo:
|
||||||
ret = log.InfoLevel
|
ret = log.InfoLevel
|
||||||
case f.WarnLevel:
|
case f.LogLevelWarn:
|
||||||
ret = log.WarnLevel
|
ret = log.WarnLevel
|
||||||
case f.ErrorLevel:
|
case f.LogLevelError:
|
||||||
ret = log.ErrorLevel
|
ret = log.ErrorLevel
|
||||||
|
case f.LogLevelFatal:
|
||||||
|
ret = log.FatalLevel
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue