diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-02-28 18:22:05 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-28 18:22:05 +0800 |
commit | 965407f2388b4da18fcc65f1e2caab3fdf5718e7 (patch) | |
tree | 6bc5102c4bc17b821aac9e7211f292d7325f900f /p2p/nat | |
parent | dc0a006c7cc4bb1a9690924bf0fd7a7da9d36384 (diff) | |
parent | 96ae35e2ac8c360781407d7294081aabdcbb3652 (diff) | |
download | dexon-965407f2388b4da18fcc65f1e2caab3fdf5718e7.tar dexon-965407f2388b4da18fcc65f1e2caab3fdf5718e7.tar.gz dexon-965407f2388b4da18fcc65f1e2caab3fdf5718e7.tar.bz2 dexon-965407f2388b4da18fcc65f1e2caab3fdf5718e7.tar.lz dexon-965407f2388b4da18fcc65f1e2caab3fdf5718e7.tar.xz dexon-965407f2388b4da18fcc65f1e2caab3fdf5718e7.tar.zst dexon-965407f2388b4da18fcc65f1e2caab3fdf5718e7.zip |
Merge pull request #3709 from fjl/p2p-context-log
p2p, p2p/discover, p2p/nat: rework logging using context keys
Diffstat (limited to 'p2p/nat')
-rw-r--r-- | p2p/nat/nat.go | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/p2p/nat/nat.go b/p2p/nat/nat.go index e5883cf98..a254648c6 100644 --- a/p2p/nat/nat.go +++ b/p2p/nat/nat.go @@ -98,16 +98,17 @@ const ( // Map adds a port mapping on m and keeps it alive until c is closed. // This function is typically invoked in its own goroutine. func Map(m Interface, c chan struct{}, protocol string, extport, intport int, name string) { + log := log.New("proto", protocol, "extport", extport, "intport", intport, "interface", m) refresh := time.NewTimer(mapUpdateInterval) defer func() { refresh.Stop() - log.Debug(fmt.Sprintf("deleting port mapping: %s %d -> %d (%s) using %s", protocol, extport, intport, name, m)) + log.Debug("Deleting port mapping") m.DeleteMapping(protocol, extport, intport) }() if err := m.AddMapping(protocol, extport, intport, name, mapTimeout); err != nil { - log.Debug(fmt.Sprintf("network port %s:%d could not be mapped: %v", protocol, intport, err)) + log.Debug("Couldn't add port mapping", "err", err) } else { - log.Info(fmt.Sprintf("mapped network port %s:%d -> %d (%s) using %s", protocol, extport, intport, name, m)) + log.Info("Mapped network port") } for { select { @@ -116,9 +117,9 @@ func Map(m Interface, c chan struct{}, protocol string, extport, intport int, na return } case <-refresh.C: - log.Trace(fmt.Sprintf("refresh port mapping %s:%d -> %d (%s) using %s", protocol, extport, intport, name, m)) + log.Trace("Refreshing port mapping") if err := m.AddMapping(protocol, extport, intport, name, mapTimeout); err != nil { - log.Debug(fmt.Sprintf("network port %s:%d could not be mapped: %v", protocol, intport, err)) + log.Debug("Couldn't add port mapping", "err", err) } refresh.Reset(mapUpdateInterval) } |