Replace message prefix with function logging

pull/1074/head
Eugene Kim 6 years ago
parent f8b04145ff
commit 9bff04a612
  1. 12
      internal/utils/connlogger.go

@ -17,22 +17,22 @@ type ConnLogger struct {
} }
func (cl ConnLogger) Listen(net net.Network, ma ma.Multiaddr) { func (cl ConnLogger) Listen(net net.Network, ma ma.Multiaddr) {
cl.l.Debug("[CONNECTIONS] Listener starting", "net", net, "addr", ma) WithCaller(cl.l).Debug("listener starting", "net", net, "addr", ma)
} }
func (cl ConnLogger) ListenClose(net net.Network, ma ma.Multiaddr) { func (cl ConnLogger) ListenClose(net net.Network, ma ma.Multiaddr) {
cl.l.Debug("[CONNECTIONS] Listener closing", "net", net, "addr", ma) WithCaller(cl.l).Debug("listener closing", "net", net, "addr", ma)
} }
func (cl ConnLogger) Connected(net net.Network, conn net.Conn) { func (cl ConnLogger) Connected(net net.Network, conn net.Conn) {
cl.l.Debug("[CONNECTIONS] Connected", "net", net, WithCaller(cl.l).Debug("connected", "net", net,
"localPeer", conn.LocalPeer(), "localAddr", conn.LocalMultiaddr(), "localPeer", conn.LocalPeer(), "localAddr", conn.LocalMultiaddr(),
"remotePeer", conn.RemotePeer(), "remoteAddr", conn.RemoteMultiaddr(), "remotePeer", conn.RemotePeer(), "remoteAddr", conn.RemoteMultiaddr(),
) )
} }
func (cl ConnLogger) Disconnected(net net.Network, conn net.Conn) { func (cl ConnLogger) Disconnected(net net.Network, conn net.Conn) {
cl.l.Debug("[CONNECTIONS] Disconnected", "net", net, WithCaller(cl.l).Debug("disconnected", "net", net,
"localPeer", conn.LocalPeer(), "localAddr", conn.LocalMultiaddr(), "localPeer", conn.LocalPeer(), "localAddr", conn.LocalMultiaddr(),
"remotePeer", conn.RemotePeer(), "remoteAddr", conn.RemoteMultiaddr(), "remotePeer", conn.RemotePeer(), "remoteAddr", conn.RemoteMultiaddr(),
) )
@ -40,7 +40,7 @@ func (cl ConnLogger) Disconnected(net net.Network, conn net.Conn) {
func (cl ConnLogger) OpenedStream(net net.Network, stream net.Stream) { func (cl ConnLogger) OpenedStream(net net.Network, stream net.Stream) {
conn := stream.Conn() conn := stream.Conn()
cl.l.Debug("[CONNECTIONS] Stream opened", "net", net, WithCaller(cl.l).Debug("stream opened", "net", net,
"localPeer", conn.LocalPeer(), "localAddr", conn.LocalMultiaddr(), "localPeer", conn.LocalPeer(), "localAddr", conn.LocalMultiaddr(),
"remotePeer", conn.RemotePeer(), "remoteAddr", conn.RemoteMultiaddr(), "remotePeer", conn.RemotePeer(), "remoteAddr", conn.RemoteMultiaddr(),
"protocol", stream.Protocol(), "protocol", stream.Protocol(),
@ -49,7 +49,7 @@ func (cl ConnLogger) OpenedStream(net net.Network, stream net.Stream) {
func (cl ConnLogger) ClosedStream(net net.Network, stream net.Stream) { func (cl ConnLogger) ClosedStream(net net.Network, stream net.Stream) {
conn := stream.Conn() conn := stream.Conn()
cl.l.Debug("[CONNECTIONS] Stream closed", "net", net, WithCaller(cl.l).Debug("stream closed", "net", net,
"localPeer", conn.LocalPeer(), "localAddr", conn.LocalMultiaddr(), "localPeer", conn.LocalPeer(), "localAddr", conn.LocalMultiaddr(),
"remotePeer", conn.RemotePeer(), "remoteAddr", conn.RemoteMultiaddr(), "remotePeer", conn.RemotePeer(), "remoteAddr", conn.RemoteMultiaddr(),
"protocol", stream.Protocol(), "protocol", stream.Protocol(),

Loading…
Cancel
Save