2022-02-28 03:15:01 +00:00
|
|
|
package validator
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/authelia/authelia/v4/internal/configuration/schema"
|
|
|
|
"github.com/authelia/authelia/v4/internal/utils"
|
|
|
|
)
|
|
|
|
|
|
|
|
// ValidateLog validates the logging configuration.
|
|
|
|
func ValidateLog(config *schema.Configuration, validator *schema.StructValidator) {
|
|
|
|
if config.Log.Level == "" {
|
|
|
|
config.Log.Level = schema.DefaultLoggingConfiguration.Level
|
|
|
|
}
|
|
|
|
|
|
|
|
if config.Log.Format == "" {
|
|
|
|
config.Log.Format = schema.DefaultLoggingConfiguration.Format
|
|
|
|
}
|
|
|
|
|
2022-12-21 10:07:00 +00:00
|
|
|
if !utils.IsStringInSlice(config.Log.Level, validLogLevels) {
|
2023-04-13 10:58:18 +00:00
|
|
|
validator.Push(fmt.Errorf(errFmtLoggingLevelInvalid, strJoinOr(validLogLevels), config.Log.Level))
|
2022-02-28 03:15:01 +00:00
|
|
|
}
|
|
|
|
}
|