aboutsummaryrefslogtreecommitdiff
path: root/handle.go
diff options
context:
space:
mode:
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)
}