Add more broker log

This commit is contained in:
Deluan 2020-11-14 00:44:58 -05:00
parent 8b2a550368
commit 1c7f859b5e

View File

@ -69,10 +69,11 @@ func (broker *broker) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
// Make sure that the writer supports flushing. // Make sure that the writer supports flushing.
flusher, ok := rw.(http.Flusher) flusher, ok := rw.(http.Flusher)
username, _ := request.UsernameFrom(req.Context()) fmt.Printf("%#v\n", req.Context())
user, _ := request.UserFrom(req.Context())
if !ok { if !ok {
log.Error(rw, "Streaming unsupported! Events cannot be sent to this client", "address", req.RemoteAddr, log.Error(rw, "Streaming unsupported! Events cannot be sent to this client", "address", req.RemoteAddr,
"userAgent", req.UserAgent(), "user", username) "userAgent", req.UserAgent(), "user", user.UserName)
http.Error(rw, "Streaming unsupported!", http.StatusInternalServerError) http.Error(rw, "Streaming unsupported!", http.StatusInternalServerError)
return return
} }
@ -88,6 +89,9 @@ func (broker *broker) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
// Signal the broker that we have a new connection // Signal the broker that we have a new connection
broker.newClients <- messageChan broker.newClients <- messageChan
log.Debug(req.Context(), "New broker client", "address", req.RemoteAddr, "userAgent", req.UserAgent(),
"user", user.UserName)
// Remove this client from the map of connected clients // Remove this client from the map of connected clients
// when this handler exits. // when this handler exits.
defer func() { defer func() {