From 7766253319bde59d77f13dba94d1b5c73f9cd3fb Mon Sep 17 00:00:00 2001 From: Nick Dumas Date: Fri, 25 Aug 2023 11:08:26 -0400 Subject: [PATCH] adding more tracing --- telnet/parser.go | 10 +++++++--- telnet/server.go | 22 ++++++++++++++++------ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/telnet/parser.go b/telnet/parser.go index 4e461d8..63f9f89 100644 --- a/telnet/parser.go +++ b/telnet/parser.go @@ -33,8 +33,12 @@ func (tp *TELNETParser) Handle() { func NewTELNETParser(c context.Context, s message.Subscriber, wml watermill.LoggerAdapter) *TELNETParser { return &TELNETParser{ - c: c, - s: s, - logger: wml, + c: c, + s: s, + logger: wml.With( + watermill.LogFields{ + "name": "TELNETParser", + }, + ), } } diff --git a/telnet/server.go b/telnet/server.go index d14fa06..131832b 100644 --- a/telnet/server.go +++ b/telnet/server.go @@ -21,17 +21,26 @@ type TELNETServer struct { func NewTELNETServer(c context.Context, l net.Listener, p message.Publisher, wml watermill.LoggerAdapter) *TELNETServer { ts := TELNETServer{ - c: c, - l: l, - p: p, - logger: wml, + c: c, + l: l, + p: p, + logger: wml.With( + watermill.LogFields{ + "name": "TELNETServer", + }, + ), } return &ts } func (ts *TELNETServer) Accept() (net.Conn, error) { - return ts.l.Accept() + conn, err := ts.l.Accept() + ts.logger.Trace("receiving telnet connection", watermill.LogFields{ + "remoteAddr": conn.RemoteAddr(), + }, + ) + return conn, err } func (ts *TELNETServer) Handle(conn net.Conn) { @@ -43,7 +52,8 @@ func (ts *TELNETServer) Handle(conn net.Conn) { correlationID := watermill.NewUUID() ts.logger = ts.logger.With( watermill.LogFields{ - "correlation_id": correlationID}, + "correlation_id": correlationID, + }, ) for s.Scan() {