aboutsummaryrefslogtreecommitdiff
path: root/handle.go
diff options
context:
space:
mode:
authorMarin Ivanov <[email protected]>2025-04-16 19:18:02 +0300
committerMarin Ivanov <[email protected]>2025-04-16 19:18:02 +0300
commit0fefc0f6c69663615025074ac2184508802d4b9d (patch)
tree44f441189a3725604376b6285b1c77326fb34efc /handle.go
parent1a339a82fe6209e463029e433a254e6d237fa17c (diff)
better loggingHEADv0.1.5master
Diffstat (limited to 'handle.go')
-rw-r--r--handle.go14
1 files changed, 6 insertions, 8 deletions
diff --git a/handle.go b/handle.go
index c153b7d..92301be 100644
--- a/handle.go
+++ b/handle.go
@@ -2,6 +2,7 @@ package main
import (
"fmt"
+ "log"
"net"
"time"
)
@@ -20,15 +21,12 @@ func protocolHandler(proto string) (protoHandler, uint16, error) {
}
}
-func logConn(conn net.Conn, msg string) {
- now := time.Now().UTC()
- fmt.Printf("%s, %s, %s\n", now.String(), conn.RemoteAddr().String(), msg)
-}
-
-func connHandler(handler protoHandler, conn net.Conn, delay time.Duration) {
+func connHandler(proto string, handler protoHandler, conn net.Conn, delay time.Duration) {
defer conn.Close()
- logConn(conn, "handling")
+ start := time.Now()
+ log.Printf("%s handling %s", conn.RemoteAddr().String(), proto)
handler(conn, delay)
- logConn(conn, "closing")
+ duration := time.Since(start)
+ log.Printf("%s ended %s lasted for %s", conn.RemoteAddr().String(), proto, duration)
}