don't configure log level if the item does not exist in the config

Reported here:
https://github.com/gustavo-iniguez-goya/opensnitch/issues/31#issuecomment-633759613

The LogLevel conf item should always exist, but just in case.
This commit is contained in:
Gustavo Iñiguez Goia 2020-06-01 01:54:08 +02:00
parent 6c9d9b28f6
commit 36a11b4102
2 changed files with 4 additions and 2 deletions

View file

@ -33,7 +33,7 @@ type Config struct {
DefaultDuration string
InterceptUnknown bool
ProcMonitorMethod string
LogLevel uint32
LogLevel *uint32
}
// Client holds the connection information of a client.

View file

@ -47,7 +47,9 @@ func (c *Client) loadConfiguration(rawConfig []byte) bool {
clientDisconnectedRule.Duration = rule.Duration(config.DefaultDuration)
clientErrorRule.Duration = rule.Duration(config.DefaultDuration)
}
log.MinLevel = int(config.LogLevel)
if config.LogLevel != nil {
log.MinLevel = int(*config.LogLevel)
}
if config.ProcMonitorMethod != "" {
procmon.MonitorMethod = config.ProcMonitorMethod
}