From 7cf5f47b2a43bfeba09bd2673c268a29ca23d856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leandro=20L=C3=B3pez=20=28inkel=29?= Date: Wed, 22 Nov 2023 12:02:31 -0300 Subject: [PATCH] Add basic logging --- main.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 5ff8891..704c424 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ import ( "bytes" "flag" "fmt" + "log" "net/http" "net/textproto" "os" @@ -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) @@ -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)) }