Consul is a distributed, highly available, and data center aware solution to connect and configure applications across dynamic, distributed infrastructure.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

39 lines
774 B

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
package logging
import (
"strings"
"github.com/hashicorp/go-hclog"
)
var (
allowedLogLevels = []string{"TRACE", "DEBUG", "INFO", "WARN", "ERR", "ERROR"}
)
func AllowedLogLevels() []string {
var c []string
copy(c, allowedLogLevels)
return c
}
// ValidateLogLevel verifies that a new log level is valid
func ValidateLogLevel(minLevel string) bool {
newLevel := strings.ToUpper(minLevel)
for _, level := range allowedLogLevels {
if level == newLevel {
return true
}
}
return false
}
// Backwards compatibility with former ERR log level
func LevelFromString(level string) hclog.Level {
if strings.ToUpper(level) == "ERR" {
level = "ERROR"
}
return hclog.LevelFromString(level)
}