mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Make logger mutable for regression test (#49146)
* Log: make logger mutable * remove flag from public configuration
This commit is contained in:
parent
71e1305364
commit
4e3f53f106
@ -378,6 +378,11 @@ func ReadLoggingConfig(modes []string, logsPath string, cfg *ini.File) error {
|
||||
return err
|
||||
}
|
||||
|
||||
logEnabled := cfg.Section("log").Key("enabled").MustBool(true)
|
||||
if !logEnabled {
|
||||
return nil
|
||||
}
|
||||
|
||||
defaultLevelName, _ := getLogLevelFromConfig("log", "info", cfg)
|
||||
defaultFilters := getFilters(util.SplitString(cfg.Section("log").Key("filters").String()))
|
||||
|
||||
|
@ -93,6 +93,7 @@ func SetUpDatabase(t *testing.T, grafDir string) *sqlstore.SQLStore {
|
||||
}
|
||||
|
||||
// CreateGrafDir creates the Grafana directory.
|
||||
// The log by default is muted in the regression test, to activate it, pass option EnableLog = true
|
||||
func CreateGrafDir(t *testing.T, opts ...GrafanaOpts) (string, string) {
|
||||
t.Helper()
|
||||
|
||||
@ -178,6 +179,7 @@ func CreateGrafDir(t *testing.T, opts ...GrafanaOpts) (string, string) {
|
||||
|
||||
logSect, err := cfg.NewSection("log")
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = logSect.NewKey("level", "debug")
|
||||
require.NoError(t, err)
|
||||
|
||||
@ -288,6 +290,12 @@ func CreateGrafDir(t *testing.T, opts ...GrafanaOpts) (string, string) {
|
||||
_, err = unifiedAlertingSection.NewKey("disabled_orgs", disableOrgStr)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
if !o.EnableLog {
|
||||
logSection, err := getOrCreateSection("log")
|
||||
require.NoError(t, err)
|
||||
_, err = logSection.NewKey("enabled", "false")
|
||||
require.NoError(t, err)
|
||||
}
|
||||
}
|
||||
|
||||
cfgPath := filepath.Join(cfgDir, "test.ini")
|
||||
@ -316,4 +324,5 @@ type GrafanaOpts struct {
|
||||
DisableLegacyAlerting bool
|
||||
EnableUnifiedAlerting bool
|
||||
UnifiedAlertingDisabledOrgs []int64
|
||||
EnableLog bool
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user