about summary refs log tree commit diff
path: root/frontend/frontend.go
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/frontend.go')
-rw-r--r--frontend/frontend.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/frontend/frontend.go b/frontend/frontend.go
index 3ef691f63b2b..f1c7857ef87c 100644
--- a/frontend/frontend.go
+++ b/frontend/frontend.go
@@ -4,12 +4,15 @@ import (
 	"fmt"
 	"io/ioutil"
 	"net/http"
+	"encoding/json"
 
 	"html/template"
 
 	"github.com/gin-gonic/gin"
 	"github.com/rakyll/statik/fs"
 
+	"github.com/apex/log"
+
 	"github.com/tweag/gerrit-queue/gerrit"
 	"github.com/tweag/gerrit-queue/misc"
 	_ "github.com/tweag/gerrit-queue/statik" // register static assets
@@ -68,6 +71,26 @@ func MakeFrontend(rotatingLogHandler *misc.RotatingLogHandler, gerritClient *ger
 			"changesetURL": func(changeset *gerrit.Changeset) string {
 				return gerritClient.GetChangesetURL(changeset)
 			},
+			"levelToClasses": func(level log.Level) string {
+				switch level {
+				case log.DebugLevel:
+					return "text-muted"
+				case log.InfoLevel:
+					return "text-info"
+				case log.WarnLevel:
+					return "text-warning"
+				case log.ErrorLevel:
+					return "text-danger"
+				case log.FatalLevel:
+					return "text-danger"
+				default:
+					return "text-white"
+				}
+			},
+			"fieldsToJSON": func(fields log.Fields) string {
+				jsonData, _ := json.Marshal(fields)
+				return string(jsonData)
+			},
 		}
 
 		tmpl := template.Must(loadTemplate([]string{