2021-06-01 04:09:50 +00:00
|
|
|
package validator
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
|
2021-08-11 01:04:35 +00:00
|
|
|
"github.com/authelia/authelia/v4/internal/configuration/schema"
|
|
|
|
"github.com/authelia/authelia/v4/internal/utils"
|
2021-06-01 04:09:50 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// ValidateLogging validates the logging configuration.
|
|
|
|
func ValidateLogging(configuration *schema.Configuration, validator *schema.StructValidator) {
|
2021-08-03 09:55:21 +00:00
|
|
|
if configuration.Log.Level == "" {
|
|
|
|
configuration.Log.Level = schema.DefaultLoggingConfiguration.Level
|
2021-06-01 04:09:50 +00:00
|
|
|
}
|
|
|
|
|
2021-08-03 09:55:21 +00:00
|
|
|
if configuration.Log.Format == "" {
|
|
|
|
configuration.Log.Format = schema.DefaultLoggingConfiguration.Format
|
2021-06-01 04:09:50 +00:00
|
|
|
}
|
|
|
|
|
2021-08-03 09:55:21 +00:00
|
|
|
if !utils.IsStringInSlice(configuration.Log.Level, validLoggingLevels) {
|
|
|
|
validator.Push(fmt.Errorf(errFmtLoggingLevelInvalid, configuration.Log.Level, strings.Join(validLoggingLevels, ", ")))
|
2021-06-01 04:09:50 +00:00
|
|
|
}
|
|
|
|
}
|