Skip to content

Commit 89fb43f

Browse files
committed
Emit payload dumps together with the preceding message
1 parent 3bfff20 commit 89fb43f

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

pkg/multiplexer/multiplexer.go

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ func (mux *Multiplexer) handleConnection(conn net.Conn, sender chan<- *reqContai
128128
}
129129

130130
if logrus.IsLevelEnabled(logrus.DebugLevel) {
131-
logrus.Debug("Message from client...")
132-
spew.Dump(msg)
131+
logrus.Debug("Message from client...\n%s", spew.Sdump(msg))
133132
}
134133

135134
// enqueue request msg to target conn loop
@@ -142,7 +141,7 @@ func (mux *Multiplexer) handleConnection(conn net.Conn, sender chan<- *reqContai
142141
// get response from target conn loop
143142
resp := <-callback
144143
if resp.err != nil {
145-
logrus.Errorf("failed to forward message, %v", err)
144+
logrus.Errorf("failed to forward message, %v", resp.err)
146145
break
147146
}
148147

@@ -183,15 +182,11 @@ func (mux *Multiplexer) targetConnLoop(requestQueue <-chan *reqContainer) {
183182
switch container.typ {
184183
case Connection:
185184
clients++
186-
if logrus.IsLevelEnabled(logrus.DebugLevel) {
187-
logrus.Debugf("Connected clients: %d", clients)
188-
}
185+
logrus.Infof("Connected clients: %d", clients)
189186
continue
190187
case Disconnection:
191188
clients--
192-
if logrus.IsLevelEnabled(logrus.DebugLevel) {
193-
logrus.Debugf("Connected clients: %d", clients)
194-
}
189+
logrus.Infof("Connected clients: %d", clients)
195190
if clients == 0 && conn != nil {
196191
logrus.Info("closing target connection")
197192
err := conn.Close()
@@ -224,7 +219,7 @@ func (mux *Multiplexer) targetConnLoop(requestQueue <-chan *reqContainer) {
224219
// renew conn
225220
err = conn.Close()
226221
if err != nil {
227-
logrus.Error(err)
222+
logrus.Error("error while closing connection: %v", err)
228223
}
229224
conn = nil
230225
continue
@@ -242,16 +237,15 @@ func (mux *Multiplexer) targetConnLoop(requestQueue <-chan *reqContainer) {
242237
}
243238

244239
if logrus.IsLevelEnabled(logrus.DebugLevel) {
245-
logrus.Debug("Message from target server...")
246-
spew.Dump(msg)
240+
logrus.Debug("Message from target server...\n%s", spew.Sdump(msg))
247241
}
248242

249243
if err != nil {
250244
logrus.Errorf("target connection: %v", err)
251245
// renew conn
252246
err = conn.Close()
253247
if err != nil {
254-
logrus.Error(err)
248+
logrus.Error("error while closing connection: %v", err)
255249
}
256250
conn = nil
257251
continue

0 commit comments

Comments
 (0)