From 19930f63e232997ff917843e79e026790bd23b5a Mon Sep 17 00:00:00 2001 From: Xavier Michelon Date: Tue, 8 Nov 2022 17:08:14 +0100 Subject: [PATCH] GODT-2046: bridge-gui log is included in optional archive sent with bug reports. --- internal/bridge/bug_report.go | 16 +++++++++++++++- internal/logging/logging.go | 4 ++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/internal/bridge/bug_report.go b/internal/bridge/bug_report.go index e22d7463..fa728d3f 100644 --- a/internal/bridge/bug_report.go +++ b/internal/bridge/bug_report.go @@ -39,7 +39,7 @@ const ( var ErrSizeTooLarge = errors.New("file is too big") // ReportBug reports a new bug from the user. -func (b *Bridge) ReportBug(osType, osVersion, description, accountName, address, emailClient string, attachLogs bool) error { +func (b *Bridge) ReportBug(osType, osVersion, description, accountName, address, emailClient string, attachLogs bool) error { //nolint:funlen if user, err := b.GetUser(address); err == nil { accountName = user.Username() } else if users := b.GetUsers(); len(users) > 0 { @@ -65,6 +65,16 @@ func (b *Bridge) ReportBug(osType, osVersion, description, accountName, address, if err != nil { log.WithError(err).Error("Can't get log files list") } + + guiLogs, err := b.getMatchingLogs( + func(filename string) bool { + return logging.MatchGUILogName(filename) && !logging.MatchStackTraceName(filename) + }, + ) + if err != nil { + log.WithError(err).Error("Can't get GUI log files list") + } + crashes, err := b.getMatchingLogs( func(filename string) bool { return logging.MatchLogName(filename) && logging.MatchStackTraceName(filename) @@ -78,6 +88,10 @@ func (b *Bridge) ReportBug(osType, osVersion, description, accountName, address, matchFiles = append(matchFiles, logs[max(0, len(logs)-(MaxCompressedFilesCount/2)):]...) matchFiles = append(matchFiles, crashes[max(0, len(crashes)-(MaxCompressedFilesCount/2)):]...) + if len(guiLogs) > 0 { + // bridge-gui is keeping only one log file and it's small (~ 1kb), so we include it regardless of file count + matchFiles = append(matchFiles, guiLogs[len(guiLogs)-1]) + } archive, err := zipFiles(matchFiles) if err != nil { diff --git a/internal/logging/logging.go b/internal/logging/logging.go index 87d2b5c1..1e573648 100644 --- a/internal/logging/logging.go +++ b/internal/logging/logging.go @@ -101,3 +101,7 @@ func getLogName(version, revision string) string { func MatchLogName(name string) bool { return regexp.MustCompile(`^v.*\.log$`).MatchString(name) } + +func MatchGUILogName(name string) bool { + return regexp.MustCompile(`^gui_v.*\.log$`).MatchString(name) +}