2015-08-16 20:54:49 +00:00
|
|
|
package agent
|
|
|
|
|
|
|
|
import (
|
2023-03-08 15:20:04 +00:00
|
|
|
"io"
|
2015-08-16 20:54:49 +00:00
|
|
|
|
|
|
|
"github.com/hashicorp/logutils"
|
|
|
|
)
|
|
|
|
|
|
|
|
// LevelFilter returns a LevelFilter that is configured with the log
|
|
|
|
// levels that we use.
|
|
|
|
func LevelFilter() *logutils.LevelFilter {
|
|
|
|
return &logutils.LevelFilter{
|
2022-03-24 20:08:03 +00:00
|
|
|
Levels: []logutils.LogLevel{"TRACE", "DEBUG", "INFO", "WARN", "ERROR", "OFF"},
|
2015-08-16 20:54:49 +00:00
|
|
|
MinLevel: "INFO",
|
2023-03-08 15:20:04 +00:00
|
|
|
Writer: io.Discard,
|
2015-08-16 20:54:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ValidateLevelFilter verifies that the log levels within the filter
|
|
|
|
// are valid.
|
|
|
|
func ValidateLevelFilter(minLevel logutils.LogLevel, filter *logutils.LevelFilter) bool {
|
|
|
|
for _, level := range filter.Levels {
|
|
|
|
if level == minLevel {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|