Sending log messages to multiple streams

Use the configured logger for all log messages.
This commit is contained in:
Grant Murphy 2018-01-23 10:02:20 +10:00
parent 51b4a4ddc8
commit 5361949a13

View file

@ -125,19 +125,19 @@ func loadConfig(configFile string) (gas.Config, error) {
func loadRules(include, exclude string) rules.RuleList {
var filters []rules.RuleFilter
if include != "" {
log.Printf("including rules: %s", include)
logger.Printf("including rules: %s", include)
including := strings.Split(include, ",")
filters = append(filters, rules.NewRuleFilter(false, including...))
} else {
log.Println("including rules: default")
logger.Println("including rules: default")
}
if exclude != "" {
log.Printf("excluding rules: %s", exclude)
logger.Printf("excluding rules: %s", exclude)
excluding := strings.Split(exclude, ",")
filters = append(filters, rules.NewRuleFilter(true, excluding...))
} else {
log.Println("excluding rules: default")
logger.Println("excluding rules: default")
}
return rules.Generate(filters...)
}
@ -192,7 +192,7 @@ func main() {
// Load enabled rule definitions
ruleDefinitions := loadRules(*flagRulesInclude, *flagRulesExclude)
if len(ruleDefinitions) <= 0 {
log.Fatal("cannot continue: no rules are configured.")
logger.Fatal("cannot continue: no rules are configured.")
}
// Create the analyzer