MM-57013 Added download button for downloading logs from server logs page in system console (#26389)

* added download system logs

* download all logs

* download all logs check-lint fix

* check lint fix

* download logs api

* download logs api working

* download logs working with error log

* linting issues and code cleanup

* CI check fix

* documented the api and logs from file with error handling

* test and final changes done

* final changes done

* Fix order of server-side translations

* Fix incorrect indentation of logs.yaml

---------

Co-authored-by: Harrison Healey <harrisonmhealey@gmail.com>
Этот коммит содержится в:
Arya Khochare
2024-06-24 23:35:23 +05:30
коммит произвёл GitHub
родитель 71c25fb316
Коммит a8b18ac807
15 изменённых файлов: 187 добавлений и 26 удалений

Просмотреть файл

@@ -728,6 +728,7 @@ type AppIface interface {
GetLatestVersion(rctx request.CTX, latestVersionUrl string) (*model.GithubReleaseInfo, *model.AppError)
GetLogs(rctx request.CTX, page, perPage int) ([]string, *model.AppError)
GetLogsSkipSend(rctx request.CTX, page, perPage int, logFilter *model.LogFilter) ([]string, *model.AppError)
GetMattermostLog(ctx request.CTX) (*model.FileData, error)
GetMemberCountsByGroup(rctx request.CTX, channelID string, includeTimezones bool) ([]*model.ChannelMemberCountByGroup, *model.AppError)
GetMessageForNotification(post *model.Post, teamName, siteUrl string, translateFunc i18n.TranslateFunc) string
GetMultipleEmojiByName(c request.CTX, names []string) ([]*model.Emoji, *model.AppError)

Просмотреть файл

@@ -7616,6 +7616,28 @@ func (a *OpenTracingAppLayer) GetMarketplacePlugins(rctx request.CTX, filter *mo
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) GetMattermostLog(ctx request.CTX) (*model.FileData, error) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetMattermostLog")
a.ctx = newCtx
a.app.Srv().Store().SetContext(newCtx)
defer func() {
a.app.Srv().Store().SetContext(origCtx)
a.ctx = origCtx
}()
defer span.Finish()
resultVar0, resultVar1 := a.app.GetMattermostLog(ctx)
if resultVar1 != nil {
span.LogFields(spanlog.Error(resultVar1))
ext.Error.Set(span, true)
}
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) GetMemberCountsByGroup(rctx request.CTX, channelID string, includeTimezones bool) ([]*model.ChannelMemberCountByGroup, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetMemberCountsByGroup")

Просмотреть файл

@@ -44,7 +44,7 @@ func (a *App) GenerateSupportPacket(c request.CTX, options *model.SupportPacketO
}
if options.IncludeLogs {
functions["mattermost log"] = a.getMattermostLog
functions["mattermost log"] = a.GetMattermostLog
functions["notification log"] = a.getNotificationsLog
}
@@ -321,7 +321,7 @@ func (a *App) getNotificationsLog(_ request.CTX) (*model.FileData, error) {
return fileData, nil
}
func (a *App) getMattermostLog(_ request.CTX) (*model.FileData, error) {
func (a *App) GetMattermostLog(ctx request.CTX) (*model.FileData, error) {
if !*a.Config().LogSettings.EnableFile {
return nil, errors.New("Unable to retrieve mattermost.log because LogSettings: EnableFile is set to false")
}

Просмотреть файл

@@ -347,7 +347,7 @@ func TestGetMattermostLog(t *testing.T) {
*cfg.LogSettings.EnableFile = false
})
fileData, err := th.App.getMattermostLog(th.Context)
fileData, err := th.App.GetMattermostLog(th.Context)
assert.Nil(t, fileData)
assert.ErrorContains(t, err, "Unable to retrieve mattermost.log because LogSettings: EnableFile is set to false")
@@ -367,7 +367,7 @@ func TestGetMattermostLog(t *testing.T) {
logLocation := config.GetLogFileLocation(dir)
// There is no mattermost.log file yet, so this fails
fileData, err = th.App.getMattermostLog(th.Context)
fileData, err = th.App.GetMattermostLog(th.Context)
assert.Nil(t, fileData)
assert.ErrorContains(t, err, "failed read mattermost log file at path "+logLocation)
@@ -376,7 +376,7 @@ func TestGetMattermostLog(t *testing.T) {
err = os.WriteFile(logLocation, d1, 0777)
require.NoError(t, err)
fileData, err = th.App.getMattermostLog(th.Context)
fileData, err = th.App.GetMattermostLog(th.Context)
require.NoError(t, err)
require.NotNil(t, fileData)
assert.Equal(t, "mattermost.log", fileData.Filename)