Log -> log

This commit is contained in:
David Wragg committed 2015-08-03 14:13:24 +01:00
1 parent 31c0506b85
commit e7ee72836d
8 files changed
+33 -33

No files matched your search

+5 -5
View File
@@ -82,11 +82,11 @@ func (conn *RemoteConnection) BreakTie(Connection) ConnectionTieBreak { return T
func (conn *RemoteConnection) Shutdown(error) {}
func (conn *RemoteConnection) Log(args ...interface{}) {
Log.Println(append(append([]interface{}{}, fmt.Sprintf("->[%s|%s]:", conn.remoteTCPAddr, conn.remote)), args...)...)
log.Println(append(append([]interface{}{}, fmt.Sprintf("->[%s|%s]:", conn.remoteTCPAddr, conn.remote)), args...)...)
}
func (conn *RemoteConnection) ErrorLog(args ...interface{}) {
Log.Errorln(append(append([]interface{}{}, fmt.Sprintf("->[%s|%s]:", conn.remoteTCPAddr, conn.remote)), args...)...)
log.Errorln(append(append([]interface{}{}, fmt.Sprintf("->[%s|%s]:", conn.remoteTCPAddr, conn.remote)), args...)...)
}
func (conn *RemoteConnection) String() string {
@@ -105,7 +105,7 @@ func (conn *RemoteConnection) String() string {
// end up in the local peer's connections map.
func StartLocalConnection(connRemote *RemoteConnection, tcpConn *net.TCPConn, udpAddr *net.UDPAddr, router *Router, acceptNewPeer bool) {
if connRemote.local != router.Ourself.Peer {
Log.Fatal("Attempt to create local connection from a peer which is not ourself")
log.Fatal("Attempt to create local connection from a peer which is not ourself")
}
// NB, we're taking a copy of connRemote here.
actionChan := make(chan ConnectionAction, ChannelSize)
@@ -231,7 +231,7 @@ func (conn *LocalConnection) ReceivedHeartbeat(remoteUDPAddr *net.UDPAddr, connU
if oldRemoteUDPAddr == nil {
return conn.sendFastHeartbeats()
} else if oldRemoteUDPAddr.String() != remoteUDPAddr.String() {
Log.Println("Peer", conn.remote, "moved from", oldRemoteUDPAddr, "to", remoteUDPAddr)
log.Println("Peer", conn.remote, "moved from", oldRemoteUDPAddr, "to", remoteUDPAddr)
}
return nil
})
@@ -486,7 +486,7 @@ func (conn *LocalConnection) actorLoop(actionChan <-chan ConnectionAction) (err
func (conn *LocalConnection) shutdown(err error) {
if conn.remote == nil {
Log.Errorf("->[%s] connection shutting down due to error during handshake: %v", conn.remoteTCPAddr, err)
log.Errorf("->[%s] connection shutting down due to error during handshake: %v", conn.remoteTCPAddr, err)
} else {
conn.ErrorLog("connection shutting down due to error:", err)
}
+2 -2
View File
@@ -297,9 +297,9 @@ func (cm *ConnectionMaker) connectToTargets(validTarget map[string]struct{}, dir
}
func (cm *ConnectionMaker) attemptConnection(address string, acceptNewPeer bool) {
Log.Printf("->[%s] attempting connection", address)
log.Printf("->[%s] attempting connection", address)
if err := cm.ourself.CreateConnection(address, acceptNewPeer); err != nil {
Log.Errorf("->[%s] error during connection attempt: %v", address, err)
log.Errorf("->[%s] error during connection attempt: %v", address, err)
cm.ConnectionTerminated(address, err)
}
}
+1 -1
View File
@@ -60,7 +60,7 @@ func (dec *EthernetDecoder) sendICMPFragNeeded(mtu int, sendFrame func([]byte) e
return err
}
Log.Printf("Sending ICMP 3,4 (%v -> %v): PMTU= %v", dec.IP.DstIP, dec.IP.SrcIP, mtu)
log.Printf("Sending ICMP 3,4 (%v -> %v): PMTU= %v", dec.IP.DstIP, dec.IP.SrcIP, mtu)
return sendFrame(buf.Bytes())
}
+1 -1
View File
@@ -224,5 +224,5 @@ func (c *GossipChannel) sendBroadcast(srcName PeerName, update GossipData) {
}
func (c *GossipChannel) log(args ...interface{}) {
Log.Println(append(append([]interface{}{}, "[gossip "+c.name+"]:"), args...)...)
log.Println(append(append([]interface{}{}, "[gossip "+c.name+"]:"), args...)...)
}
+9 -9
View File
@@ -40,13 +40,13 @@ func (peer *LocalPeer) Relay(srcPeer, dstPeer *Peer, frame []byte, dec *Ethernet
if !found {
// Not necessarily an error as there could be a race with the
// dst disappearing whilst the frame is in flight
Log.Println("Received packet for unknown destination:", dstPeer)
log.Println("Received packet for unknown destination:", dstPeer)
return nil
}
conn, found := peer.ConnectionTo(relayPeerName)
if !found {
// Again, could just be a race, not necessarily an error
Log.Println("Unable to find connection to relay peer", relayPeerName)
log.Println("Unable to find connection to relay peer", relayPeerName)
return nil
}
return conn.(*LocalConnection).Forward(&ForwardedFrame{
@@ -69,9 +69,9 @@ func (peer *LocalPeer) RelayBroadcast(srcPeer *Peer, frame []byte, dec *Ethernet
dec)
if err != nil {
if ftbe, ok := err.(FrameTooBigError); ok {
Log.Warningf("dropping too big DF broadcast frame (%v -> %v): PMTU= %v", dec.IP.DstIP, dec.IP.SrcIP, ftbe.EPMTU)
log.Warningf("dropping too big DF broadcast frame (%v -> %v): PMTU= %v", dec.IP.DstIP, dec.IP.SrcIP, ftbe.EPMTU)
} else {
Log.Errorln(err)
log.Errorln(err)
}
}
}
@@ -180,10 +180,10 @@ func (peer *LocalPeer) actorLoop(actionChan <-chan LocalPeerAction) {
func (peer *LocalPeer) handleAddConnection(conn Connection) error {
if peer.Peer != conn.Local() {
Log.Fatal("Attempt made to add connection to peer where peer is not the source of connection")
log.Fatal("Attempt made to add connection to peer where peer is not the source of connection")
}
if conn.Remote() == nil {
Log.Fatal("Attempt made to add connection to peer with unknown remote peer")
log.Fatal("Attempt made to add connection to peer with unknown remote peer")
}
toName := conn.Remote().Name
dupErr := fmt.Errorf("Multiple connections to %s added to %s", conn.Remote(), peer.String())
@@ -222,7 +222,7 @@ func (peer *LocalPeer) handleAddConnection(conn Connection) error {
func (peer *LocalPeer) handleConnectionEstablished(conn Connection) {
if peer.Peer != conn.Local() {
Log.Fatal("Peer informed of active connection where peer is not the source of connection")
log.Fatal("Peer informed of active connection where peer is not the source of connection")
}
if dupConn, found := peer.connections[conn.Remote().Name]; !found || conn != dupConn {
conn.Shutdown(fmt.Errorf("Cannot set unknown connection active"))
@@ -235,10 +235,10 @@ func (peer *LocalPeer) handleConnectionEstablished(conn Connection) {
func (peer *LocalPeer) handleDeleteConnection(conn Connection) {
if peer.Peer != conn.Local() {
Log.Fatal("Attempt made to delete connection from peer where peer is not the source of connection")
log.Fatal("Attempt made to delete connection from peer where peer is not the source of connection")
}
if conn.Remote() == nil {
Log.Fatal("Attempt made to delete connection to peer with unknown remote peer")
log.Fatal("Attempt made to delete connection to peer with unknown remote peer")
}
toName := conn.Remote().Name
if connFound, found := peer.connections[toName]; !found || connFound != conn {
+11 -11
View File
@@ -67,11 +67,11 @@ type PacketSourceSink interface {
func NewRouter(config Config, name PeerName, nickName string) *Router {
router := &Router{Config: config, gossipChannels: make(GossipChannels)}
onMacExpiry := func(mac net.HardwareAddr, peer *Peer) {
Log.Println("Expired MAC", mac, "at", peer)
log.Println("Expired MAC", mac, "at", peer)
}
onPeerGC := func(peer *Peer) {
router.Macs.Delete(peer)
Log.Println("Removed unreachable peer", peer)
log.Println("Removed unreachable peer", peer)
}
router.Ourself = NewLocalPeer(name, nickName, router)
router.Macs = NewMacCache(macMaxAge, onMacExpiry)
@@ -136,12 +136,12 @@ func onOff(b bool) string {
}
func (router *Router) sniff(pio PacketSourceSink) {
Log.Println("Sniffing traffic on", router.Iface)
log.Println("Sniffing traffic on", router.Iface)
dec := NewEthernetDecoder()
mac := router.Iface.HardwareAddr
if router.Macs.Enter(mac, router.Ourself.Peer) {
Log.Println("Discovered our MAC", mac)
log.Println("Discovered our MAC", mac)
}
go func() {
for {
@@ -168,7 +168,7 @@ func (router *Router) handleCapturedPacket(frameData []byte, dec *EthernetDecode
return
}
if router.Macs.Enter(srcMac, router.Ourself.Peer) {
Log.Println("Discovered local MAC", srcMac)
log.Println("Discovered local MAC", srcMac)
}
if dec.DropFrame() {
return
@@ -211,7 +211,7 @@ func (router *Router) listenTCP(localPort int) {
for {
tcpConn, err := ln.AcceptTCP()
if err != nil {
Log.Errorln(err)
log.Errorln(err)
continue
}
router.acceptTCP(tcpConn)
@@ -225,7 +225,7 @@ func (router *Router) acceptTCP(tcpConn *net.TCPConn) {
// on router.Port and we wait for them to send us something on UDP to
// start.
remoteAddrStr := tcpConn.RemoteAddr().String()
Log.Printf("->[%s] connection accepted", remoteAddrStr)
log.Printf("->[%s] connection accepted", remoteAddrStr)
connRemote := NewRemoteConnection(router.Ourself.Peer, nil, remoteAddrStr, false, false)
StartLocalConnection(connRemote, tcpConn, nil, router, true)
}
@@ -255,10 +255,10 @@ func (router *Router) udpReader(conn *net.UDPConn, po PacketSink) {
if err == io.EOF {
return
} else if err != nil {
Log.Warnln("ignoring UDP read error", err)
log.Warnln("ignoring UDP read error", err)
continue
} else if n < NameSize {
Log.Warnln("ignoring too short UDP packet from", sender)
log.Warnln("ignoring too short UDP packet from", sender)
continue
}
name := PeerNameFromBin(buf[:NameSize])
@@ -335,7 +335,7 @@ func (router *Router) handleUDPPacketFunc(relayConn *LocalConnection, dec *Ether
dstMac := dec.Eth.DstMAC
if router.Macs.Enter(srcMac, srcPeer) {
Log.Println("Discovered remote MAC", srcMac, "at", srcPeer)
log.Println("Discovered remote MAC", srcMac, "at", srcPeer)
}
if po != nil {
router.LogFrame("Injecting", frame, dec)
@@ -421,7 +421,7 @@ func (router *Router) applyTopologyUpdate(update []byte) (PeerNameSet, PeerNameS
// itself included in the update, and we didn't know about
// already. We ignore this; eventually we should receive an
// update containing a complete topology.
Log.Println("Topology gossip:", err)
log.Println("Topology gossip:", err)
return nil, nil, nil
}
if err != nil {
+1 -1
View File
@@ -86,7 +86,7 @@ func (sender *RawUDPSender) Send(msg []byte) error {
}
defer f.Close()
fd := int(f.Fd())
Log.Println("EMSGSIZE on send, expecting PMTU update (IP packet was",
log.Println("EMSGSIZE on send, expecting PMTU update (IP packet was",
len(packet), "bytes, payload was", len(msg), "bytes)")
pmtu, err := syscall.GetsockoptInt(fd, syscall.IPPROTO_IP, syscall.IP_MTU)
if err != nil {
+3 -3
View File
@@ -10,19 +10,19 @@ import (
"github.com/weaveworks/weave/common"
)
var Log = common.Log
var log = common.Log
var void = struct{}{}
func checkFatal(e error) {
if e != nil {
Log.Fatal(e)
log.Fatal(e)
}
}
func checkWarn(e error) {
if e != nil {
Log.Warnln(e)
log.Warnln(e)
}
}