Files

77 lines
1.8 KiB
Go
Raw Permalink Normal View History

package v2
2024-07-23 14:48:37 +08:00
import (
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
2026-07-17 17:54:36 +08:00
"github.com/1Panel-dev/1Panel/agent/app/dto"
2024-07-23 14:48:37 +08:00
"github.com/gin-gonic/gin"
)
// @Tags Logs
// @Summary Load system log files
2025-01-21 18:32:14 +08:00
// @Success 200 {array} string
2024-07-23 14:48:37 +08:00
// @Security ApiKeyAuth
2025-01-21 18:32:14 +08:00
// @Security Timestamp
2024-07-23 14:48:37 +08:00
// @Router /logs/system/files [get]
func (b *BaseApi) GetSystemFiles(c *gin.Context) {
data, err := logService.ListSystemLogFile()
if err != nil {
2024-10-29 18:42:12 +08:00
helper.InternalServer(c, err)
2024-07-23 14:48:37 +08:00
return
}
helper.SuccessWithData(c, data)
}
2026-07-17 17:54:36 +08:00
// @Tags Logs
// @Summary Get host system log status
// @Produce json
// @Success 200 {object} dto.SystemLogStatus
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /logs/system/status [get]
func (b *BaseApi) GetSystemLogStatus(c *gin.Context) {
data, err := logService.GetSystemLogStatus()
if err != nil {
helper.InternalServer(c, err)
return
}
helper.SuccessWithData(c, data)
}
2026-07-17 17:54:36 +08:00
// @Tags Logs
// @Summary Read host logs
// @Accept json
// @Param request body dto.SystemLogReq true "request"
// @Produce json
// @Success 200 {object} dto.SystemLogRes
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /logs/system/read [post]
func (b *BaseApi) ReadSystemLog(c *gin.Context) {
var req dto.SystemLogReq
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
data, err := logService.ReadSystemLog(req)
if err != nil {
helper.InternalServer(c, err)
return
}
helper.SuccessWithData(c, data)
}
// @Tags Logs
// @Summary List running host services
// @Produce json
// @Success 200 {array} string
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /logs/system/services [get]
func (b *BaseApi) ListRunningServices(c *gin.Context) {
data, err := logService.ListRunningServices()
if err != nil {
helper.InternalServer(c, err)
return
}
helper.SuccessWithData(c, data)
}