wgengine/wglog: add a prefix for all wireguard logs

Fixes #7041

Signed-off-by: James Tucker <james@tailscale.com>
This commit is contained in:
James Tucker
2023-01-23 14:05:33 -08:00
committed by James Tucker
parent 06fff461dc
commit e002260b62
2 changed files with 5 additions and 4 deletions
+3 -2
View File
@@ -36,6 +36,7 @@ type strCache struct {
// This logger silences repetitive/unhelpful noisy log lines
// and rewrites peer keys from wireguard-go into Tailscale format.
func NewLogger(logf logger.Logf) *Logger {
const prefix = "wg: "
ret := new(Logger)
wrapper := func(format string, args ...any) {
if strings.Contains(format, "Routine:") && !strings.Contains(format, "receive incoming") {
@@ -81,8 +82,8 @@ func NewLogger(logf logger.Logf) *Logger {
logf(format, newargs...)
}
ret.DeviceLogger = &device.Logger{
Verbosef: logger.WithPrefix(wrapper, "[v2] "),
Errorf: wrapper,
Verbosef: logger.WithPrefix(wrapper, prefix+"[v2] "),
Errorf: logger.WithPrefix(wrapper, prefix),
}
ret.strs = make(map[key.NodePublic]*strCache)
return ret