|
|
@ -77,32 +77,32 @@ func NewConfig() Config { |
|
|
|
|
|
|
|
|
|
|
|
// LookupConfig - lookup logger config, override with ENVs if set.
|
|
|
|
// LookupConfig - lookup logger config, override with ENVs if set.
|
|
|
|
func LookupConfig(cfg Config) (Config, error) { |
|
|
|
func LookupConfig(cfg Config) (Config, error) { |
|
|
|
|
|
|
|
if cfg.HTTP == nil { |
|
|
|
|
|
|
|
cfg.HTTP = make(map[string]HTTP) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if cfg.Audit == nil { |
|
|
|
|
|
|
|
cfg.Audit = make(map[string]HTTP) |
|
|
|
|
|
|
|
} |
|
|
|
envs := env.List(EnvLoggerHTTPEndpoint) |
|
|
|
envs := env.List(EnvLoggerHTTPEndpoint) |
|
|
|
for _, e := range envs { |
|
|
|
for _, k := range envs { |
|
|
|
target := strings.TrimPrefix(e, EnvLoggerHTTPEndpoint) |
|
|
|
target := strings.TrimPrefix(k, EnvLoggerHTTPEndpoint+defaultTarget) |
|
|
|
if target == "" { |
|
|
|
if target == EnvLoggerHTTPEndpoint { |
|
|
|
target = defaultTarget |
|
|
|
target = defaultTarget |
|
|
|
} |
|
|
|
} |
|
|
|
_, ok := cfg.HTTP[target] |
|
|
|
cfg.HTTP[target] = HTTP{ |
|
|
|
if ok { |
|
|
|
Enabled: true, |
|
|
|
cfg.HTTP[target] = HTTP{ |
|
|
|
Endpoint: env.Get(k, cfg.HTTP[target].Endpoint), |
|
|
|
Enabled: true, |
|
|
|
|
|
|
|
Endpoint: env.Get(e, cfg.HTTP[target].Endpoint), |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
aenvs := env.List(EnvAuditLoggerHTTPEndpoint) |
|
|
|
aenvs := env.List(EnvAuditLoggerHTTPEndpoint) |
|
|
|
for _, e := range aenvs { |
|
|
|
for _, k := range aenvs { |
|
|
|
target := strings.TrimPrefix(e, EnvAuditLoggerHTTPEndpoint) |
|
|
|
target := strings.TrimPrefix(k, EnvAuditLoggerHTTPEndpoint+defaultTarget) |
|
|
|
if target == "" { |
|
|
|
if target == EnvAuditLoggerHTTPEndpoint { |
|
|
|
target = defaultTarget |
|
|
|
target = defaultTarget |
|
|
|
} |
|
|
|
} |
|
|
|
_, ok := cfg.Audit[target] |
|
|
|
cfg.Audit[target] = HTTP{ |
|
|
|
if ok { |
|
|
|
Enabled: true, |
|
|
|
cfg.Audit[target] = HTTP{ |
|
|
|
Endpoint: env.Get(k, cfg.Audit[target].Endpoint), |
|
|
|
Enabled: true, |
|
|
|
|
|
|
|
Endpoint: env.Get(e, cfg.Audit[target].Endpoint), |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|