Chore: Make logger mutable for regression test (#49146)
* Log: make logger mutable * remove flag from public configuration
This commit is contained in:
@@ -378,6 +378,11 @@ func ReadLoggingConfig(modes []string, logsPath string, cfg *ini.File) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logEnabled := cfg.Section("log").Key("enabled").MustBool(true)
|
||||||
|
if !logEnabled {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
defaultLevelName, _ := getLogLevelFromConfig("log", "info", cfg)
|
defaultLevelName, _ := getLogLevelFromConfig("log", "info", cfg)
|
||||||
defaultFilters := getFilters(util.SplitString(cfg.Section("log").Key("filters").String()))
|
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.
|
// 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) {
|
func CreateGrafDir(t *testing.T, opts ...GrafanaOpts) (string, string) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
@@ -178,6 +179,7 @@ func CreateGrafDir(t *testing.T, opts ...GrafanaOpts) (string, string) {
|
|||||||
|
|
||||||
logSect, err := cfg.NewSection("log")
|
logSect, err := cfg.NewSection("log")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
_, err = logSect.NewKey("level", "debug")
|
_, err = logSect.NewKey("level", "debug")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@@ -288,6 +290,12 @@ func CreateGrafDir(t *testing.T, opts ...GrafanaOpts) (string, string) {
|
|||||||
_, err = unifiedAlertingSection.NewKey("disabled_orgs", disableOrgStr)
|
_, err = unifiedAlertingSection.NewKey("disabled_orgs", disableOrgStr)
|
||||||
require.NoError(t, err)
|
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")
|
cfgPath := filepath.Join(cfgDir, "test.ini")
|
||||||
@@ -316,4 +324,5 @@ type GrafanaOpts struct {
|
|||||||
DisableLegacyAlerting bool
|
DisableLegacyAlerting bool
|
||||||
EnableUnifiedAlerting bool
|
EnableUnifiedAlerting bool
|
||||||
UnifiedAlertingDisabledOrgs []int64
|
UnifiedAlertingDisabledOrgs []int64
|
||||||
|
EnableLog bool
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user