Merge pull request #510 from sumeshpremraj/spremraj/improve-network-debug-logging

Convert line payloads to string for debug logging
This commit is contained in:
Matthias Rampke 2023-07-10 22:39:30 +02:00 committed by GitHub
commit 871e2d8df1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -133,7 +133,7 @@ func (l *StatsDTCPListener) HandleConn(c *net.TCPConn) {
}
break
}
level.Debug(l.Logger).Log("msg", "Incoming line", "proto", "tcp", "line", line)
level.Debug(l.Logger).Log("msg", "Incoming line", "proto", "tcp", "line", string(line))
if isPrefix {
l.TCPLineTooLong.Inc()
level.Debug(l.Logger).Log("msg", "Read failed: line too long", "addr", c.RemoteAddr())

View file

@ -127,7 +127,7 @@ func (r *Relay) relayOutput() {
buffer.Reset()
buffer.Write(b)
} else {
level.Debug(r.logger).Log("msg", "Adding line to buffer", "line", b)
level.Debug(r.logger).Log("msg", "Adding line to buffer", "line", string(b))
buffer.Write(b)
}
}
@ -140,7 +140,7 @@ func (r *Relay) sendPacket(buf []byte) error {
level.Debug(r.logger).Log("msg", "Empty buffer, nothing to send")
return nil
}
level.Debug(r.logger).Log("msg", "Sending packet", "length", len(buf), "data", buf)
level.Debug(r.logger).Log("msg", "Sending packet", "length", len(buf), "data", string(buf))
_, err := r.conn.WriteToUDP(buf, r.addr)
r.packetsTotal.Inc()
return err
@ -158,7 +158,7 @@ func (r *Relay) RelayLine(l string) {
r.longLinesTotal.Inc()
return
}
level.Debug(r.logger).Log("msg", "Relaying line", "line", l)
level.Debug(r.logger).Log("msg", "Relaying line", "line", string(l))
if !strings.HasSuffix(l, "\n") {
l = l + "\n"
}