mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(logging): progress on new logging #4590
This commit is contained in:
@@ -2,6 +2,7 @@ package login
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/grafana/grafana/pkg/log"
|
||||
@@ -49,21 +50,24 @@ type LdapGroupToOrgRole struct {
|
||||
}
|
||||
|
||||
var ldapCfg LdapConfig
|
||||
var ldapLogger log.Logger = log.New("ldap")
|
||||
|
||||
func loadLdapConfig() {
|
||||
if !setting.LdapEnabled {
|
||||
return
|
||||
}
|
||||
|
||||
log.Info("Login: Ldap enabled, reading config file: %s", setting.LdapConfigFile)
|
||||
ldapLogger.Info("Ldap enabled, reading config file", "file", setting.LdapConfigFile)
|
||||
|
||||
_, err := toml.DecodeFile(setting.LdapConfigFile, &ldapCfg)
|
||||
if err != nil {
|
||||
log.Fatal(3, "Failed to load ldap config file: %s", err)
|
||||
ldapLogger.Crit("Failed to load ldap config file", "error", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if len(ldapCfg.Servers) == 0 {
|
||||
log.Fatal(3, "ldap enabled but no ldap servers defined in config file: %s", setting.LdapConfigFile)
|
||||
ldapLogger.Crit("ldap enabled but no ldap servers defined in config file")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// set default org id
|
||||
@@ -83,11 +87,13 @@ func assertNotEmptyCfg(val interface{}, propName string) {
|
||||
switch v := val.(type) {
|
||||
case string:
|
||||
if v == "" {
|
||||
log.Fatal(3, "LDAP config file is missing option: %s", propName)
|
||||
ldapLogger.Crit("LDAP config file is missing option", "option", propName)
|
||||
os.Exit(1)
|
||||
}
|
||||
case []string:
|
||||
if len(v) == 0 {
|
||||
log.Fatal(3, "LDAP config file is missing option: %s", propName)
|
||||
ldapLogger.Crit("LDAP config file is missing option", "option", propName)
|
||||
os.Exit(1)
|
||||
}
|
||||
default:
|
||||
fmt.Println("unknown")
|
||||
|
||||
Reference in New Issue
Block a user