mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-16 15:26:40 +00:00
Move log collection into platform-dispatched addPlatformLog(): - Android: dumps logcat buffer via /system/bin/logcat -d - Other platforms: existing file-based log + systemd fallback
35 lines
716 B
Go
35 lines
716 B
Go
//go:build android
|
|
|
|
package debug
|
|
|
|
import (
|
|
"fmt"
|
|
"os/exec"
|
|
"strings"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func (g *BundleGenerator) addPlatformLog() error {
|
|
cmd := exec.Command("/system/bin/logcat", "-d")
|
|
out, err := cmd.Output()
|
|
if err != nil {
|
|
return fmt.Errorf("run logcat: %w", err)
|
|
}
|
|
|
|
var logReader *strings.Reader
|
|
if g.anonymize {
|
|
anonymized := g.anonymizer.AnonymizeString(string(out))
|
|
logReader = strings.NewReader(anonymized)
|
|
} else {
|
|
logReader = strings.NewReader(string(out))
|
|
}
|
|
|
|
if err := g.addFileToZip(logReader, "logcat.txt"); err != nil {
|
|
return fmt.Errorf("add logcat to zip: %w", err)
|
|
}
|
|
|
|
log.Debugf("added logcat output to debug bundle (%d bytes)", len(out))
|
|
return nil
|
|
}
|