improved logging
This commit is contained in:
parent
f8407162ad
commit
05b41cedce
81 changed files with 9802 additions and 279 deletions
|
|
@ -5,7 +5,6 @@ package server
|
|||
import (
|
||||
"embed"
|
||||
"errors"
|
||||
"git.giftfish.de/ston1th/docstore/pkg/log"
|
||||
"html/template"
|
||||
"io/fs"
|
||||
)
|
||||
|
|
@ -13,19 +12,19 @@ import (
|
|||
//go:embed templates/*
|
||||
var templates embed.FS
|
||||
|
||||
func (s *HTTPServer) loadTemplates() {
|
||||
func (s *HTTPServer) loadTemplates() error {
|
||||
var fatal bool
|
||||
s.templ = make(map[string]*template.Template)
|
||||
s.res = make(map[string][]byte)
|
||||
tfs, err := fs.Sub(templates, "templates")
|
||||
if err != nil {
|
||||
log.Fatal("parse: ", err)
|
||||
return err
|
||||
}
|
||||
parse := func(html ...string) (temp *template.Template) {
|
||||
var err error
|
||||
temp, err = template.ParseFS(tfs, html...)
|
||||
if err != nil {
|
||||
log.Println("parse:", err)
|
||||
s.Log.Error(err, "template parser")
|
||||
fatal = true
|
||||
}
|
||||
return
|
||||
|
|
@ -61,6 +60,7 @@ func (s *HTTPServer) loadTemplates() {
|
|||
s.templ["logsHandler"] = parse("index.html", "menu.html", "logs.html")
|
||||
|
||||
if fatal {
|
||||
log.Fatal("parse: ", errors.New("parsing templates failed"))
|
||||
return errors.New("parsing templates failed")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue