()
| 550 | } |
| 551 | |
| 552 | func (h *handler) handlePutConfig() error { |
| 553 | |
| 554 | type FileLoggerPutConfig struct { |
| 555 | Enabled *bool `json:"enabled,omitempty"` |
| 556 | } |
| 557 | |
| 558 | type ConsoleLoggerPutConfig struct { |
| 559 | LogLevel *base.LogLevel `json:"log_level,omitempty"` |
| 560 | LogKeys []string `json:"log_keys,omitempty"` |
| 561 | } |
| 562 | |
| 563 | // Probably need to make our own to remove log file path / redaction level |
| 564 | type ServerPutConfig struct { |
| 565 | Logging struct { |
| 566 | Console *ConsoleLoggerPutConfig `json:"console,omitempty"` |
| 567 | Error FileLoggerPutConfig `json:"error,omitempty"` |
| 568 | Warn FileLoggerPutConfig `json:"warn,omitempty"` |
| 569 | Info FileLoggerPutConfig `json:"info,omitempty"` |
| 570 | Debug FileLoggerPutConfig `json:"debug,omitempty"` |
| 571 | Trace FileLoggerPutConfig `json:"trace,omitempty"` |
| 572 | Stats FileLoggerPutConfig `json:"stats,omitempty"` |
| 573 | Audit FileLoggerPutConfig `json:"audit,omitempty"` |
| 574 | } `json:"logging"` |
| 575 | ReplicationLimit *int `json:"max_concurrent_replications,omitempty"` |
| 576 | } |
| 577 | |
| 578 | var config ServerPutConfig |
| 579 | err := base.WrapJSONUnknownFieldErr(ReadJSONFromMIMERawErr(h.rq.Header, h.requestBody, &config)) |
| 580 | if err != nil { |
| 581 | if pkgerrors.Cause(err) == base.ErrUnknownField { |
| 582 | return base.HTTPErrorf(http.StatusBadRequest, "Unable to configure given options at runtime: %v", err) |
| 583 | } |
| 584 | return err |
| 585 | } |
| 586 | |
| 587 | // Go over all loggers and use |
| 588 | if config.Logging.Console != nil { |
| 589 | if config.Logging.Console.LogLevel != nil { |
| 590 | base.ConsoleLogLevel().Set(*config.Logging.Console.LogLevel) |
| 591 | } |
| 592 | |
| 593 | if config.Logging.Console.LogKeys != nil { |
| 594 | testMap := make(map[string]bool) |
| 595 | for _, key := range config.Logging.Console.LogKeys { |
| 596 | testMap[key] = true |
| 597 | } |
| 598 | |
| 599 | base.UpdateLogKeys(h.ctx(), testMap, true) |
| 600 | } |
| 601 | } |
| 602 | |
| 603 | if config.Logging.Error.Enabled != nil { |
| 604 | base.EnableErrorLogger(*config.Logging.Error.Enabled) |
| 605 | } |
| 606 | |
| 607 | if config.Logging.Warn.Enabled != nil { |
| 608 | base.EnableWarnLogger(*config.Logging.Warn.Enabled) |
| 609 | } |
nothing calls this directly
no test coverage detected