mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-16 11:41:39 +00:00
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
|
// This logger silences repetitive/unhelpful noisy log lines
|
||||||
// and rewrites peer keys from wireguard-go into Tailscale format.
|
// and rewrites peer keys from wireguard-go into Tailscale format.
|
||||||
func NewLogger(logf logger.Logf) *Logger {
|
func NewLogger(logf logger.Logf) *Logger {
|
||||||
|
const prefix = "wg: "
|
||||||
ret := new(Logger)
|
ret := new(Logger)
|
||||||
wrapper := func(format string, args ...any) {
|
wrapper := func(format string, args ...any) {
|
||||||
if strings.Contains(format, "Routine:") && !strings.Contains(format, "receive incoming") {
|
if strings.Contains(format, "Routine:") && !strings.Contains(format, "receive incoming") {
|
||||||
@ -81,8 +82,8 @@ func NewLogger(logf logger.Logf) *Logger {
|
|||||||
logf(format, newargs...)
|
logf(format, newargs...)
|
||||||
}
|
}
|
||||||
ret.DeviceLogger = &device.Logger{
|
ret.DeviceLogger = &device.Logger{
|
||||||
Verbosef: logger.WithPrefix(wrapper, "[v2] "),
|
Verbosef: logger.WithPrefix(wrapper, prefix+"[v2] "),
|
||||||
Errorf: wrapper,
|
Errorf: logger.WithPrefix(wrapper, prefix),
|
||||||
}
|
}
|
||||||
ret.strs = make(map[key.NodePublic]*strCache)
|
ret.strs = make(map[key.NodePublic]*strCache)
|
||||||
return ret
|
return ret
|
||||||
|
@ -22,9 +22,9 @@ func TestLogger(t *testing.T) {
|
|||||||
want string
|
want string
|
||||||
omit bool
|
omit bool
|
||||||
}{
|
}{
|
||||||
{"hi", nil, "hi", false},
|
{"hi", nil, "wg: hi", false},
|
||||||
{"Routine: starting", nil, "", true},
|
{"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 {
|
type log struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user