about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--frontend/frontend.go23
-rw-r--r--go.sum1
-rw-r--r--public/index.tmpl.html21
3 files changed, 39 insertions, 6 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{
diff --git a/go.sum b/go.sum
index 78d9662c9383..a72f3de27f7d 100644
--- a/go.sum
+++ b/go.sum
@@ -71,6 +71,7 @@ golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8U
 golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
 golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
 golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI=
 golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
diff --git a/public/index.tmpl.html b/public/index.tmpl.html
index bc145c5b6426..d7ec29c25053 100644
--- a/public/index.tmpl.html
+++ b/public/index.tmpl.html
@@ -63,15 +63,24 @@
     {{ end }}
 
     <h2 id="region-log">Log</h2>
-    <table class="table">
+    <table class="table .table-sm">
       <tbody>
-        <tr>
-          <td class="bg-dark text-white">
-            {{ range $entry := .memory.Entries }}
-            <code>{{ $entry }}</code><br />
-            {{ end }}
+        {{ range $entry := .memory.Entries }}
+        <tr class="bg-dark {{ levelToClasses $entry.Level }}">
+          <td rowspan="2">
+            {{ $entry.Timestamp.Format "2006-01-02 15:04:05 UTC"}}
+          </td>
+          <td>{{ $entry.Level }}</td>
+          <td>
+            <code class="{{ levelToClasses $entry.Level }}">{{ $entry.Message }}</code><br />
+          </td>
+        </tr>
+        <tr class="bg-dark {{ levelToClasses $entry.Level }}">
+          <td colspan="2">
+              <code class="{{ levelToClasses $entry.Level }}">{{ fieldsToJSON $entry.Fields }}</code><br />
           </td>
         </tr>
+        {{ end }}
       </tbody>
     </table>
 </body>