summaryrefslogtreecommitdiffstats
path: root/main.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 /main.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 'main.go')
-rw-r--r--main.go17
1 files changed, 7 insertions, 10 deletions
diff --git a/main.go b/main.go
index 3d7f23f..40c8070 100644
--- a/main.go
+++ b/main.go
@@ -95,16 +95,14 @@ func main() {
logLevel := func() int {
switch os.Getenv("LOG_LEVEL") {
- case "debug":
- return device.LogLevelDebug
- case "info":
- return device.LogLevelInfo
+ case "verbose", "debug":
+ return device.LogLevelVerbose
case "error":
return device.LogLevelError
case "silent":
return device.LogLevelSilent
}
- return device.LogLevelInfo
+ return device.LogLevelError
}()
// open TUN device (or use supplied fd)
@@ -143,8 +141,7 @@ func main() {
fmt.Sprintf("(%s) ", interfaceName),
)
- logger.Infof("Starting wireguard-go version %v", device.WireGuardGoVersion)
- logger.Debugf("Debug log enabled")
+ logger.Verbosef("Starting wireguard-go version %s", device.WireGuardGoVersion)
if err != nil {
logger.Errorf("Failed to create TUN device: %v", err)
@@ -224,7 +221,7 @@ func main() {
device := device.NewDevice(tun, logger)
- logger.Infof("Device started")
+ logger.Verbosef("Device started")
errs := make(chan error)
term := make(chan os.Signal, 1)
@@ -246,7 +243,7 @@ func main() {
}
}()
- logger.Infof("UAPI listener started")
+ logger.Verbosef("UAPI listener started")
// wait for program to terminate
@@ -264,5 +261,5 @@ func main() {
uapi.Close()
device.Close()
- logger.Infof("Shutting down")
+ logger.Verbosef("Shutting down")
}