2022-08-16 15:30:23 +00:00
|
|
|
package v1
|
|
|
|
|
|
|
|
import (
|
2022-10-17 08:32:31 +00:00
|
|
|
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
|
|
|
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
|
|
|
"github.com/1Panel-dev/1Panel/backend/constant"
|
2022-08-16 15:30:23 +00:00
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
|
2023-09-20 08:24:26 +00:00
|
|
|
// @Tags Logs
|
|
|
|
// @Summary Load system log files
|
|
|
|
// @Description 获取系统日志文件列表
|
|
|
|
// @Success 200
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @Router /logs/system/files [get]
|
|
|
|
func (b *BaseApi) GetSystemFiles(c *gin.Context) {
|
|
|
|
data, err := logService.ListSystemLogFile()
|
|
|
|
if err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
helper.SuccessWithData(c, data)
|
|
|
|
}
|
|
|
|
|
2023-08-02 08:47:30 +00:00
|
|
|
// @Tags Logs
|
|
|
|
// @Summary Load system logs
|
|
|
|
// @Description 获取系统日志
|
|
|
|
// @Success 200
|
|
|
|
// @Security ApiKeyAuth
|
2023-09-20 08:24:26 +00:00
|
|
|
// @Router /logs/system [post]
|
2023-08-02 08:47:30 +00:00
|
|
|
func (b *BaseApi) GetSystemLogs(c *gin.Context) {
|
2023-09-20 08:24:26 +00:00
|
|
|
var req dto.OperationWithName
|
2023-10-27 06:19:26 +00:00
|
|
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
2023-09-20 08:24:26 +00:00
|
|
|
return
|
|
|
|
}
|
2023-10-27 06:19:26 +00:00
|
|
|
|
2023-09-20 08:24:26 +00:00
|
|
|
data, err := logService.LoadSystemLog(req.Name)
|
2023-08-02 08:47:30 +00:00
|
|
|
if err != nil {
|
|
|
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
helper.SuccessWithData(c, data)
|
|
|
|
}
|