github.com/hhrutter/nomad@v0.6.0-rc2.0.20170723054333-80c4b03f0705/command/agent/log_levels.go (about) 1 package agent 2 3 import ( 4 "io/ioutil" 5 6 "github.com/hashicorp/logutils" 7 ) 8 9 // LevelFilter returns a LevelFilter that is configured with the log 10 // levels that we use. 11 func LevelFilter() *logutils.LevelFilter { 12 return &logutils.LevelFilter{ 13 Levels: []logutils.LogLevel{"TRACE", "DEBUG", "INFO", "WARN", "ERR"}, 14 MinLevel: "INFO", 15 Writer: ioutil.Discard, 16 } 17 } 18 19 // ValidateLevelFilter verifies that the log levels within the filter 20 // are valid. 21 func ValidateLevelFilter(minLevel logutils.LogLevel, filter *logutils.LevelFilter) bool { 22 for _, level := range filter.Levels { 23 if level == minLevel { 24 return true 25 } 26 } 27 return false 28 }