Skip to content

Commit

Permalink
Add basic logging
Browse files Browse the repository at this point in the history
  • Loading branch information
inkel committed Nov 22, 2023
1 parent 9378bf0 commit 7cf5f47
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"flag"
"fmt"
"log"
"net/http"
"net/textproto"
"os"
Expand Down Expand Up @@ -43,7 +44,7 @@ func main() {
bodyBytes := buf.Bytes()

http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {

log.Printf("method=%s uri=%q remote-addr=%v", r.Method, r.RequestURI, r.RemoteAddr)
for key, values := range headers {
for _, value := range values {
w.Header().Add(key, value)
Expand All @@ -54,6 +55,6 @@ func main() {
w.Write(bodyBytes)
})

fmt.Printf("Starting lruc on %v\n", *addr)
log.Printf(`msg="Starting lruc" addr=%v code=%d content-type=%q body-bytes=%d`, *addr, *code, *ct, len(bodyBytes))
fmt.Println(http.ListenAndServe(*addr, nil))
}

0 comments on commit 7cf5f47

Please sign in to comment.