about summary refs log tree commit diff
path: root/frontend/frontend.go
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2019-12-04T14·21+0100
committerFlorian Klink <flokli@flokli.de>2019-12-04T14·21+0100
commitea04792c39604267fdb4fa9d83841f5a08c0003e (patch)
treea19b074bdcc98b06adc6d32d390b9a95e1d3d7d2 /frontend/frontend.go
parentbdfdad2585737c5760971889fd5def32e14b38c5 (diff)
frontend: improve log display
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{