MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / GetWebsiteLog

Method GetWebsiteLog

agent/app/service/website.go:1128–1158  ·  view source on GitHub ↗
(req request.WebsiteLogSearchReq)

Source from the content-addressed store, hash-verified

1126}
1127
1128func (w WebsiteService) GetWebsiteLog(req request.WebsiteLogSearchReq) (*response.WebsiteLog, error) {
1129 website, err := websiteRepo.GetFirst(repo.WithByID(req.ID))
1130 if err != nil {
1131 return nil, err
1132 }
1133 sitePath := GetSitePath(website, SiteDir)
1134 res := &response.WebsiteLog{
1135 Content: "",
1136 }
1137 switch req.LogType {
1138 case constant.AccessLog:
1139 res.Enable = website.AccessLog
1140 if !website.AccessLog {
1141 return res, nil
1142 }
1143 case constant.ErrorLog:
1144 res.Enable = website.ErrorLog
1145 if !website.ErrorLog {
1146 return res, nil
1147 }
1148 }
1149 filePath := path.Join(sitePath, "log", req.LogType)
1150 logFileRes, err := files.ReadFileByLine(filePath, req.Page, req.PageSize, false)
1151 if err != nil {
1152 return nil, err
1153 }
1154 res.End = logFileRes.IsEndOfFile
1155 res.Path = filePath
1156 res.Content = strings.Join(logFileRes.Lines, "\n")
1157 return res, nil
1158}
1159
1160func (w WebsiteService) OpWebsiteLog(req request.WebsiteLogReq) error {
1161 website, err := websiteRepo.GetFirst(repo.WithByID(req.ID))

Callers

nothing calls this directly

Calls 4

GetSitePathFunction · 0.85
ReadFileByLineMethod · 0.80
GetFirstMethod · 0.65
WithByIDMethod · 0.65

Tested by

no test coverage detected