(req request.WebsiteLogSearchReq)
| 1126 | } |
| 1127 | |
| 1128 | func (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 | |
| 1160 | func (w WebsiteService) OpWebsiteLog(req request.WebsiteLogReq) error { |
| 1161 | website, err := websiteRepo.GetFirst(repo.WithByID(req.ID)) |
nothing calls this directly
no test coverage detected