aboutsummaryrefslogtreecommitdiffstats
path: root/device/device.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-01-26 23:05:48 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2021-01-26 23:05:48 +0100
commitd669c78c4306290963415568f4a64a1ae2b35b20 (patch)
tree189a833daf57ffded2e177bfe5a554fd1b886392 /device/device.go
parentdevice: change logging interface to use functions (diff)
downloadwireguard-go-d669c78c4306290963415568f4a64a1ae2b35b20.tar.xz
wireguard-go-d669c78c4306290963415568f4a64a1ae2b35b20.zip
device: combine debug and info log levels into 'verbose'
There are very few cases, if any, in which a user only wants one of these levels, so combine it into a single level. While we're at it, reduce indirection on the loggers by using an empty function rather than a nil function pointer. It's not like we have retpolines anyway, and we were always calling through a function with a branch prior, so this seems like a net gain. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'device/device.go')
-rw-r--r--device/device.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/device/device.go b/device/device.go
index 27c42f2..ebcbd9e 100644
--- a/device/device.go
+++ b/device/device.go
@@ -177,7 +177,7 @@ func deviceUpdateState(device *Device) {
switch newIsUp {
case true:
if err := device.BindUpdate(); err != nil {
- device.errorf("Unable to update bind: %v", err)
+ device.log.Errorf("Unable to update bind: %v", err)
device.isUp.Set(false)
break
}
@@ -303,7 +303,7 @@ func NewDevice(tunDevice tun.Device, logger *Logger) *Device {
device.tun.device = tunDevice
mtu, err := device.tun.device.MTU()
if err != nil {
- device.errorf("Trouble determining MTU, assuming default: %v", err)
+ device.log.Errorf("Trouble determining MTU, assuming default: %v", err)
mtu = DefaultMTU
}
device.tun.mtu = int32(mtu)
@@ -397,7 +397,7 @@ func (device *Device) Close() {
return
}
- device.infof("Device closing")
+ device.log.Verbosef("Device closing")
device.state.changing.Set(true)
device.state.Lock()
defer device.state.Unlock()
@@ -422,7 +422,7 @@ func (device *Device) Close() {
device.rate.limiter.Close()
device.state.changing.Set(false)
- device.infof("Interface closed")
+ device.log.Verbosef("Interface closed")
}
func (device *Device) Wait() chan struct{} {
@@ -562,7 +562,7 @@ func (device *Device) BindUpdate() error {
go device.RoutineReceiveIncoming(ipv4.Version, netc.bind)
go device.RoutineReceiveIncoming(ipv6.Version, netc.bind)
- device.debugf("UDP bind has been updated")
+ device.log.Verbosef("UDP bind has been updated")
}
return nil