diff options
Diffstat (limited to 'handle.go')
| -rw-r--r-- | handle.go | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -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) } |
