mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2025-07-23 04:51:39 +02:00
add more information to existing errors logs and panics
- '$ROOT/$FILE' for better localization in the code - add text where none was given - fix unnecessary sprintf nesting in influxv2 and prometheus metricrepo logging
This commit is contained in:
@@ -24,6 +24,7 @@ var frontendFiles embed.FS
|
||||
func ServeFiles() http.Handler {
|
||||
publicFiles, err := fs.Sub(frontendFiles, "frontend/public")
|
||||
if err != nil {
|
||||
log.Fatalf("WEB/WEB > cannot find frontend public files")
|
||||
panic(err)
|
||||
}
|
||||
return http.FileServer(http.FS(publicFiles))
|
||||
@@ -47,6 +48,7 @@ func init() {
|
||||
templates[strings.TrimPrefix(path, "templates/")] = template.Must(template.Must(base.Clone()).ParseFS(templateFiles, path))
|
||||
return nil
|
||||
}); err != nil {
|
||||
log.Fatalf("WEB/WEB > cannot find frontend template files")
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -80,6 +82,7 @@ type Page struct {
|
||||
func RenderTemplate(rw http.ResponseWriter, r *http.Request, file string, page *Page) {
|
||||
t, ok := templates[file]
|
||||
if !ok {
|
||||
log.Fatalf("WEB/WEB > template '%s' not found", file)
|
||||
panic("template not found")
|
||||
}
|
||||
|
||||
@@ -91,6 +94,6 @@ func RenderTemplate(rw http.ResponseWriter, r *http.Request, file string, page *
|
||||
|
||||
log.Infof("%v\n", page.Config)
|
||||
if err := t.Execute(rw, page); err != nil {
|
||||
log.Errorf("template error: %s", err.Error())
|
||||
log.Errorf("WEB/WEB > template error: %s", err.Error())
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user