constellation/internal/logger/cmdline.go
Daniel Weiße 0a874496b3 Add verbosity flag to all services (#244)
Signed-off-by: Daniel Weiße <dw@edgeless.systems>
2022-07-01 16:17:06 +02:00

25 lines
583 B
Go

package logger
import (
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
const CmdLineVerbosityDescription = "log verbosity in zap logging levels. Use -1 for debug information, 0 for info, 1 for warn, 2 for error"
// VerbosityFromInt converts a verbosity level from an integer to a zapcore.Level.
func VerbosityFromInt(verbosity int) zapcore.Level {
switch {
case verbosity <= -1:
return zap.DebugLevel
case verbosity == 0:
return zap.InfoLevel
case verbosity == 1:
return zap.WarnLevel
case verbosity >= 2:
return zap.ErrorLevel
default:
return zap.InfoLevel
}
}