mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
remove the global log error/warn etc functions (#41404)
* remove the global log error/warn etc functions and use request context logger whenever possible
This commit is contained in:
@@ -11,6 +11,8 @@ import (
|
||||
api "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
|
||||
)
|
||||
|
||||
var cfglogger = log.New("notifier.config")
|
||||
|
||||
func PersistTemplates(cfg *api.PostableUserConfig, path string) ([]string, bool, error) {
|
||||
if len(cfg.TemplateFiles) < 1 {
|
||||
return nil, false, nil
|
||||
@@ -52,7 +54,7 @@ func PersistTemplates(cfg *api.PostableUserConfig, path string) ([]string, bool,
|
||||
// Now that we have the list of _actual_ templates, let's remove the ones that we don't need.
|
||||
existingFiles, err := ioutil.ReadDir(path)
|
||||
if err != nil {
|
||||
log.Error("unable to read directory for deleting Alertmanager templates", "err", err, "path", path)
|
||||
cfglogger.Error("unable to read directory for deleting Alertmanager templates", "err", err, "path", path)
|
||||
}
|
||||
for _, existingFile := range existingFiles {
|
||||
p := filepath.Join(path, existingFile.Name())
|
||||
@@ -61,7 +63,7 @@ func PersistTemplates(cfg *api.PostableUserConfig, path string) ([]string, bool,
|
||||
templatesChanged = true
|
||||
err := os.Remove(p)
|
||||
if err != nil {
|
||||
log.Error("unable to delete template", "err", err, "file", p)
|
||||
cfglogger.Error("unable to delete template", "err", err, "file", p)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -543,7 +543,7 @@ func (sch *schedule) ruleRoutine(grafanaCtx context.Context, key models.AlertRul
|
||||
return evaluate(currentRule, attempt, ctx)
|
||||
})
|
||||
if err != nil {
|
||||
log.Error("evaluation failed after all retries", "err", err)
|
||||
logger.Error("evaluation failed after all retries", "err", err)
|
||||
}
|
||||
}()
|
||||
case <-stopCh:
|
||||
|
||||
Reference in New Issue
Block a user