wgengine/wglog: add a prefix for all wireguard logs
Fixes #7041 Signed-off-by: James Tucker <james@tailscale.com>
This commit is contained in:
parent
06fff461dc
commit
e002260b62
|
@ -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
|
||||
|
|
|
@ -22,9 +22,9 @@ func TestLogger(t *testing.T) {
|
|||
want string
|
||||
omit bool
|
||||
}{
|
||||
{"hi", nil, "hi", false},
|
||||
{"hi", nil, "wg: hi", false},
|
||||
{"Routine: starting", nil, "", true},
|
||||
{"%v says it misses you", []any{stringer("peer(IMTB…r7lM)")}, "[IMTBr] says it misses you", false},
|
||||
{"%v says it misses you", []any{stringer("peer(IMTB…r7lM)")}, "wg: [IMTBr] says it misses you", false},
|
||||
}
|
||||
|
||||
type log struct {
|
||||
|
|
Loading…
Reference in New Issue