mirror of
https://github.com/spaytac/orbiter.git
synced 2026-01-22 07:54:41 +00:00
Format logrus has json
This commit is contained in:
parent
1709cf5150
commit
d2a86fef18
@ -10,11 +10,13 @@ import (
|
|||||||
func Events(eventChannel chan *logrus.Entry) func(w http.ResponseWriter, r *http.Request) {
|
func Events(eventChannel chan *logrus.Entry) func(w http.ResponseWriter, r *http.Request) {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
logrus.Info("New events")
|
logrus.Info("New events")
|
||||||
|
formatter := &logrus.JSONFormatter{}
|
||||||
flusher, _ := w.(http.Flusher)
|
flusher, _ := w.(http.Flusher)
|
||||||
for {
|
for {
|
||||||
e := <-eventChannel
|
e := <-eventChannel
|
||||||
fmt.Fprintf(w, "Ciao %d\n", e.Message)
|
b, _ := formatter.Format(e)
|
||||||
flusher.Flush() // Trigger "chunked" encoding and send a chunk...
|
fmt.Fprintf(w, string(b))
|
||||||
|
flusher.Flush()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user