Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Move checking logLevel and pluginTrust values to separate function an…
Browse files Browse the repository at this point in the history
…d occur earlier in the startup process of pulsed
  • Loading branch information
geauxvirtual committed Oct 23, 2015
1 parent 718c433 commit 87c940f
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions pulse.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,8 @@ func action(ctx *cli.Context) {
// Set Max Processors for pulsed.
setMaxProcs(maxProcs)

if logLevel < 1 || logLevel > 5 {
log.WithFields(
log.Fields{
"block": "main",
"_module": "pulsed",
"level": logLevel,
}).Fatal("log level was invalid (needs: 1-5)")
os.Exit(1)
}
// Validate log level and trust level settings for pulsed
validateLevelSettings(logLevel, pluginTrust)

if logPath != "" {
f, err := os.Stat(logPath)
Expand Down Expand Up @@ -336,15 +329,6 @@ func action(ctx *cli.Context) {
}

//Plugin Trust
if pluginTrust < 0 || pluginTrust > 2 {
log.WithFields(
log.Fields{
"block": "main",
"_module": "pulsed",
"level": pluginTrust,
}).Fatal("Plugin trust was invalid (needs: 0-2)")
os.Exit(1)
}
c.SetPluginTrustLevel(pluginTrust)
log.Info("setting plugin trust level to: ", t[pluginTrust])
//Keyring checking for trust levels 1 and 2
Expand Down Expand Up @@ -613,3 +597,24 @@ func getLevel(i int) log.Level {
panic("bad level")
}
}

func validateLevelSettings(logLevel, pluginTrust int) {
if logLevel < 1 || logLevel > 5 {
log.WithFields(
log.Fields{
"block": "main",
"_module": "pulsed",
"level": logLevel,
}).Fatal("log level was invalid (needs: 1-5)")
os.Exit(1)
}
if pluginTrust < 0 || pluginTrust > 2 {
log.WithFields(
log.Fields{
"block": "main",
"_module": "pulsed",
"level": pluginTrust,
}).Fatal("Plugin trust was invalid (needs: 0-2)")
os.Exit(1)
}
}

0 comments on commit 87c940f

Please sign in to comment.