summaryrefslogtreecommitdiffstats
path: root/utils/html.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2018-04-27 12:49:45 -0700
committerGitHub <noreply@github.com>2018-04-27 12:49:45 -0700
commit686c2fbab7607d42183ae685a27ea3d7dce8c3f6 (patch)
tree53ed73cada57bc43f342ac10e2f842cddb095218 /utils/html.go
parent2acbc77d78456d7ba76ceb687b18985d7d92f814 (diff)
downloadchat-686c2fbab7607d42183ae685a27ea3d7dce8c3f6.tar.gz
chat-686c2fbab7607d42183ae685a27ea3d7dce8c3f6.tar.bz2
chat-686c2fbab7607d42183ae685a27ea3d7dce8c3f6.zip
Structured logging (#8673)
* Implementing structured logging * Changes to en.json to allow refactor to run. * Fixing global logger * Structured logger initalization. * Add caller. * Do some log redirection. * Auto refactor * Cleaning up l4g reference and removing dependancy. * Removing junk. * Copyright headers. * Fixing tests * Revert "Changes to en.json to allow refactor to run." This reverts commit fd8249e99bcad0231e6ea65cd77c32aae9a54026. * Fixing some auto refactor strangeness and typo. * Making keys more human readable.
Diffstat (limited to 'utils/html.go')
-rw-r--r--utils/html.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/utils/html.go b/utils/html.go
index f9a7abe5b..0de33435d 100644
--- a/utils/html.go
+++ b/utils/html.go
@@ -6,14 +6,15 @@ package utils
import (
"bytes"
"errors"
+ "fmt"
"html/template"
"io"
"path/filepath"
"reflect"
"sync/atomic"
- l4g "github.com/alecthomas/log4go"
"github.com/fsnotify/fsnotify"
+ "github.com/mattermost/mattermost-server/mlog"
"github.com/nicksnyder/go-i18n/i18n"
)
@@ -25,7 +26,7 @@ type HTMLTemplateWatcher struct {
func NewHTMLTemplateWatcher(directory string) (*HTMLTemplateWatcher, error) {
templatesDir, _ := FindDir(directory)
- l4g.Debug("Parsing server templates at %v", templatesDir)
+ mlog.Debug(fmt.Sprintf("Parsing server templates at %v", templatesDir))
ret := &HTMLTemplateWatcher{
stop: make(chan struct{}),
@@ -57,15 +58,15 @@ func NewHTMLTemplateWatcher(directory string) (*HTMLTemplateWatcher, error) {
return
case event := <-watcher.Events:
if event.Op&fsnotify.Write == fsnotify.Write {
- l4g.Info("Re-parsing templates because of modified file %v", event.Name)
+ mlog.Info(fmt.Sprintf("Re-parsing templates because of modified file %v", event.Name))
if htmlTemplates, err := template.ParseGlob(filepath.Join(templatesDir, "*.html")); err != nil {
- l4g.Error("Failed to parse templates %v", err)
+ mlog.Error(fmt.Sprintf("Failed to parse templates %v", err))
} else {
ret.templates.Store(htmlTemplates)
}
}
case err := <-watcher.Errors:
- l4g.Error("Failed in directory watcher %s", err)
+ mlog.Error(fmt.Sprintf("Failed in directory watcher %s", err))
}
}
}()
@@ -110,7 +111,7 @@ func (t *HTMLTemplate) RenderToWriter(w io.Writer) error {
}
if err := t.Templates.ExecuteTemplate(w, t.TemplateName, t); err != nil {
- l4g.Error(T("api.api.render.error"), t.TemplateName, err)
+ mlog.Error(fmt.Sprintf("Error rendering template %v err=%v", t.TemplateName, err))
return err
}
@@ -134,7 +135,7 @@ func escapeForHtml(arg interface{}) interface{} {
}
return safeArg
default:
- l4g.Warn("Unable to escape value for HTML template %v of type %v", arg, reflect.ValueOf(arg).Type())
+ mlog.Warn(fmt.Sprintf("Unable to escape value for HTML template %v of type %v", arg, reflect.ValueOf(arg).Type()))
return ""
}
}