diff --git a/utils/html.go b/utils/html.go
index a3512c5a0a..fbf88730fa 100644
--- a/utils/html.go
+++ b/utils/html.go
@@ -6,7 +6,6 @@ package utils
import (
"bytes"
"errors"
- "fmt"
"html/template"
"io"
"path/filepath"
@@ -28,7 +27,7 @@ type HTMLTemplateWatcher struct {
func NewHTMLTemplateWatcher(directory string) (*HTMLTemplateWatcher, error) {
templatesDir, _ := fileutils.FindDir(directory)
- mlog.Debug(fmt.Sprintf("Parsing server templates at %v", templatesDir))
+ mlog.Debug("Parsing server templates", mlog.String("templates_directory", templatesDir))
ret := &HTMLTemplateWatcher{
stop: make(chan struct{}),
@@ -60,15 +59,15 @@ func NewHTMLTemplateWatcher(directory string) (*HTMLTemplateWatcher, error) {
return
case event := <-watcher.Events:
if event.Op&fsnotify.Write == fsnotify.Write {
- mlog.Info(fmt.Sprintf("Re-parsing templates because of modified file %v", event.Name))
+ mlog.Info("Re-parsing templates because of modified file", mlog.String("file_name", event.Name))
if htmlTemplates, err := template.ParseGlob(filepath.Join(templatesDir, "*.html")); err != nil {
- mlog.Error(fmt.Sprintf("Failed to parse templates %v", err))
+ mlog.Error("Failed to parse templates.", mlog.Err(err))
} else {
ret.templates.Store(htmlTemplates)
}
}
case err := <-watcher.Errors:
- mlog.Error(fmt.Sprintf("Failed in directory watcher %s", err))
+ mlog.Error("Failed in directory watcher", mlog.Err(err))
}
}
}()
@@ -113,7 +112,7 @@ func (t *HTMLTemplate) RenderToWriter(w io.Writer) error {
}
if err := t.Templates.ExecuteTemplate(w, t.TemplateName, t); err != nil {
- mlog.Error(fmt.Sprintf("Error rendering template %v err=%v", t.TemplateName, err))
+ mlog.Error("Error rendering template", mlog.String("template_name", t.TemplateName), mlog.Err(err))
return err
}
@@ -140,7 +139,11 @@ func escapeForHtml(arg interface{}) interface{} {
}
return safeArg
default:
- mlog.Warn(fmt.Sprintf("Unable to escape value for HTML template %v of type %v", arg, reflect.ValueOf(arg).Type()))
+ mlog.Warn(
+ "Unable to escape value for HTML template",
+ mlog.Any("html_template", arg),
+ mlog.String("template_type", reflect.ValueOf(arg).Type().String()),
+ )
return ""
}
}