mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-12-18 13:29:03 +08:00
feat: Restrict the size of log files to read. (#9147)
This commit is contained in:
parent
0c31fcc8a3
commit
146b628cc1
9 changed files with 26 additions and 1 deletions
|
|
@ -108,6 +108,7 @@ ErrSourcePathNotFound: 'Source directory does not exist'
|
||||||
ErrFavoriteExist: 'This path has already been favorited'
|
ErrFavoriteExist: 'This path has already been favorited'
|
||||||
ErrInvalidChar: 'Illegal characters are not allowed'
|
ErrInvalidChar: 'Illegal characters are not allowed'
|
||||||
ErrPathNotDelete: 'The selected directory cannot be deleted'
|
ErrPathNotDelete: 'The selected directory cannot be deleted'
|
||||||
|
ErrLogFileToLarge: "The log file exceeds 500MB and cannot be opened"
|
||||||
|
|
||||||
#website
|
#website
|
||||||
ErrAliasIsExist: 'Alias already exists'
|
ErrAliasIsExist: 'Alias already exists'
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,7 @@ ErrSourcePathNotFound: 'ソース ディレクトリが存在しません'
|
||||||
ErrFavoriteExist: 'このパスはすでにお気に入りに登録されています'
|
ErrFavoriteExist: 'このパスはすでにお気に入りに登録されています'
|
||||||
ErrInvalidChar: '不正な文字は許可されません'
|
ErrInvalidChar: '不正な文字は許可されません'
|
||||||
ErrPathNotDelete: '選択されたディレクトリは削除できません'
|
ErrPathNotDelete: '選択されたディレクトリは削除できません'
|
||||||
|
ErrLogFileToLarge: "ログファイルが500MBを超えており、開くことができません"
|
||||||
|
|
||||||
#website
|
#website
|
||||||
ErrAliasIsExist: 'エイリアスがすでに存在します'
|
ErrAliasIsExist: 'エイリアスがすでに存在します'
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,7 @@ ErrSourcePathNotFound: '소스 디렉토리가 존재하지 않습니다'
|
||||||
ErrFavoriteExist: '이 경로는 이미 즐겨찾기되었습니다'
|
ErrFavoriteExist: '이 경로는 이미 즐겨찾기되었습니다'
|
||||||
ErrInvalidChar: '불법 문자는 허용되지 않습니다'
|
ErrInvalidChar: '불법 문자는 허용되지 않습니다'
|
||||||
ErrPathNotDelete: '선택한 디렉토리를 삭제할 수 없습니다'
|
ErrPathNotDelete: '선택한 디렉토리를 삭제할 수 없습니다'
|
||||||
|
ErrLogFileToLarge: "로그 파일이 500MB를 초과하여 열 수 없습니다"
|
||||||
|
|
||||||
#웹사이트
|
#웹사이트
|
||||||
ErrAliasIsExist: '별칭이 이미 존재합니다'
|
ErrAliasIsExist: '별칭이 이미 존재합니다'
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,7 @@ ErrSourcePathNotFound: 'O diretório de origem não existe'
|
||||||
ErrFavoriteExist: 'Este caminho já foi favorito'
|
ErrFavoriteExist: 'Este caminho já foi favorito'
|
||||||
ErrInvalidChar: 'Caracteres ilegais não são permitidos'
|
ErrInvalidChar: 'Caracteres ilegais não são permitidos'
|
||||||
ErrPathNotDelete: 'O diretório selecionado não pode ser excluído'
|
ErrPathNotDelete: 'O diretório selecionado não pode ser excluído'
|
||||||
|
ErrLogFileToLarge: "Fail log melebihi 500MB, tidak boleh dibuka"
|
||||||
|
|
||||||
#site
|
#site
|
||||||
ErrAliasIsExist: 'Alias já existe'
|
ErrAliasIsExist: 'Alias já existe'
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,7 @@ ErrSourcePathNotFound: 'Исходный каталог не существуе
|
||||||
ErrFavoriteExist: 'Этот путь уже добавлен в избранное'
|
ErrFavoriteExist: 'Этот путь уже добавлен в избранное'
|
||||||
ErrInvalidChar: 'Недопустимые символы не допускаются'
|
ErrInvalidChar: 'Недопустимые символы не допускаются'
|
||||||
ErrPathNotDelete: 'Выбранный каталог не может быть удален'
|
ErrPathNotDelete: 'Выбранный каталог не может быть удален'
|
||||||
|
ErrLogFileToLarge: "Файл журнала превышает 500MB и не может быть открыт"
|
||||||
|
|
||||||
#веб-сайт
|
#веб-сайт
|
||||||
ErrAliasIsExist: 'Псевдоним уже существует'
|
ErrAliasIsExist: 'Псевдоним уже существует'
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,7 @@ ErrSourcePathNotFound: '來源目錄不存在'
|
||||||
ErrFavoriteExist: '已收藏此路徑'
|
ErrFavoriteExist: '已收藏此路徑'
|
||||||
ErrInvalidChar: '禁止使用非法字元'
|
ErrInvalidChar: '禁止使用非法字元'
|
||||||
ErrPathNotDelete: '所選目錄不可刪除'
|
ErrPathNotDelete: '所選目錄不可刪除'
|
||||||
|
ErrLogFileToLarge: "日志文件超过 500M,無法打開"
|
||||||
|
|
||||||
#website
|
#website
|
||||||
ErrAliasIsExist: '代號已存在'
|
ErrAliasIsExist: '代號已存在'
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,7 @@ ErrSourcePathNotFound: "源目录不存在"
|
||||||
ErrFavoriteExist: "已收藏此路径"
|
ErrFavoriteExist: "已收藏此路径"
|
||||||
ErrInvalidChar: "禁止使用非法字符"
|
ErrInvalidChar: "禁止使用非法字符"
|
||||||
ErrPathNotDelete: "所选目录不可删除"
|
ErrPathNotDelete: "所选目录不可删除"
|
||||||
|
ErrLogFileToLarge: "日志文件超过 500M,无法打开"
|
||||||
|
|
||||||
#website
|
#website
|
||||||
ErrAliasIsExist: "代号已存在"
|
ErrAliasIsExist: "代号已存在"
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/buserr"
|
||||||
"github.com/1Panel-dev/1Panel/agent/constant"
|
"github.com/1Panel-dev/1Panel/agent/constant"
|
||||||
"github.com/1Panel-dev/1Panel/agent/utils/req_helper"
|
"github.com/1Panel-dev/1Panel/agent/utils/req_helper"
|
||||||
"io"
|
"io"
|
||||||
|
|
@ -103,6 +104,16 @@ func ReadFileByLine(filename string, page, pageSize int, latest bool) (lines []s
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
|
fi, err := file.Stat()
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if fi.Size() > 500*1024*1024 {
|
||||||
|
err = buserr.New("ErrLogFileToLarge")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
totalLines, err := countLines(filename)
|
totalLines, err := countLines(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -205,7 +205,14 @@ const getContent = async (pre: boolean) => {
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
emit('update:isReading', true);
|
emit('update:isReading', true);
|
||||||
|
|
||||||
const res = await readByLine(readReq, props.config.operateNode || '');
|
let res;
|
||||||
|
try {
|
||||||
|
res = await readByLine(readReq, props.config.operateNode || '');
|
||||||
|
} catch (error) {
|
||||||
|
isLoading.value = false;
|
||||||
|
firstLoading.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
logPath.value = res.data.path;
|
logPath.value = res.data.path;
|
||||||
firstLoading.value = false;
|
firstLoading.value = false;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue