diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/admin.go | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/app/admin.go b/app/admin.go index c551da50c..509d81840 100644 --- a/app/admin.go +++ b/app/admin.go @@ -18,14 +18,14 @@ import ( "github.com/mattermost/platform/utils" ) -func GetLogs() ([]string, *model.AppError) { - lines, err := GetLogsSkipSend() +func GetLogs(page, perPage int) ([]string, *model.AppError) { + lines, err := GetLogsSkipSend(page, perPage) if err != nil { return nil, err } if einterfaces.GetClusterInterface() != nil { - clines, err := einterfaces.GetClusterInterface().GetLogs() + clines, err := einterfaces.GetClusterInterface().GetLogs(page, perPage) if err != nil { return nil, err } @@ -36,7 +36,7 @@ func GetLogs() ([]string, *model.AppError) { return lines, nil } -func GetLogsSkipSend() ([]string, *model.AppError) { +func GetLogsSkipSend(page, perPage int) ([]string, *model.AppError) { var lines []string if utils.Cfg.LogSettings.EnableFile { @@ -47,9 +47,20 @@ func GetLogsSkipSend() ([]string, *model.AppError) { defer file.Close() + offsetCount := 0 + limitCount := 0 scanner := bufio.NewScanner(file) for scanner.Scan() { - lines = append(lines, scanner.Text()) + if limitCount >= perPage { + break + } + + if offsetCount >= page*perPage { + lines = append(lines, scanner.Text()) + limitCount++ + } else { + offsetCount++ + } } } else { lines = append(lines, "") |