Skip to content
Snippets Groups Projects
Commit b2b6f717 authored by ale's avatar ale
Browse files

log received messages

parent 62427c28
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,10 @@ package server
import (
"encoding/json"
"log"
"net"
"net/http"
"strings"
"time"
"git.autistici.org/ai/audit"
......@@ -34,7 +37,13 @@ func (h *HttpServer) writeHandler(w http.ResponseWriter, r *http.Request) {
return
}
// Request was successful, return empty 200 OK reply.
// Request was successful, log it and return empty 200 OK reply.
var hostStr string
if host, _, err := net.SplitHostPort(r.RemoteAddr); err != nil {
hostStr = host
}
logText := strings.TrimRight(string(msg.ToJSON()), "\n")
log.Printf("%s: received message: %s", hostStr, logText)
w.WriteHeader(200)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment