mirror of
https://github.com/safing/portbase
synced 2025-09-01 18:19:57 +00:00
Only set initial log level if flag is set
This commit is contained in:
parent
3d9920935e
commit
53a45b72ef
2 changed files with 8 additions and 6 deletions
|
@ -8,6 +8,6 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
flag.StringVar(&logLevelFlag, "log", "info", "set log level to [trace|debug|info|warning|error|critical]")
|
flag.StringVar(&logLevelFlag, "log", "", "set log level to [trace|debug|info|warning|error|critical]")
|
||||||
flag.StringVar(&pkgLogLevelsFlag, "plog", "", "set log level of packages: database=trace,notifications=debug")
|
flag.StringVar(&pkgLogLevelsFlag, "plog", "", "set log level of packages: database=trace,notifications=debug")
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,12 +137,14 @@ func Start() (err error) {
|
||||||
|
|
||||||
logBuffer = make(chan *logLine, 1024)
|
logBuffer = make(chan *logLine, 1024)
|
||||||
|
|
||||||
initialLogLevel := ParseLevel(logLevelFlag)
|
if logLevelFlag != "" {
|
||||||
if initialLogLevel > 0 {
|
initialLogLevel := ParseLevel(logLevelFlag)
|
||||||
|
if initialLogLevel == 0 {
|
||||||
|
fmt.Fprintf(os.Stderr, "log warning: invalid log level \"%s\", falling back to level info\n", logLevelFlag)
|
||||||
|
initialLogLevel = InfoLevel
|
||||||
|
}
|
||||||
|
|
||||||
SetLogLevel(initialLogLevel)
|
SetLogLevel(initialLogLevel)
|
||||||
} else {
|
|
||||||
err = fmt.Errorf("log warning: invalid log level \"%s\", falling back to level info", logLevelFlag)
|
|
||||||
fmt.Fprintf(os.Stderr, "%s\n", err.Error())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get and set file loglevels
|
// get and set file loglevels
|
||||||
|
|
Loading…
Add table
Reference in a new issue