mirror of
https://codeberg.org/pluja/kycnot.me
synced 2025-01-09 06:07:56 -05:00
improve logs
This commit is contained in:
parent
be261a4595
commit
cb27dbb57c
@ -42,19 +42,17 @@ func (s *Server) handleApiPicture(c iris.Context) {
|
||||
|
||||
service, err := database.Pb.GetServiceById(id)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Could not get service")
|
||||
log.Error().Err(err).Msg("GetPicture: Could not get service")
|
||||
respondWithPlaceholder(c, "?")
|
||||
return
|
||||
}
|
||||
|
||||
if service.LogoURL == "" {
|
||||
log.Debug().Msgf("Image %s not found in cache", service.ID)
|
||||
respondWithPlaceholder(c, service.Name)
|
||||
return
|
||||
}
|
||||
|
||||
if imageData, err := s.Cache.Get(fmt.Sprintf("img-%s", service.ID)); err == nil {
|
||||
log.Debug().Msgf("Found image %s in cache", service.ID)
|
||||
ctt, _ := s.Cache.Get(fmt.Sprintf("ctt-%s", service.ID))
|
||||
c.ContentType(string(ctt))
|
||||
c.StatusCode(iris.StatusOK)
|
||||
@ -62,11 +60,10 @@ func (s *Server) handleApiPicture(c iris.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
log.Debug().Msgf("Image %s not found in cache", service.ID)
|
||||
client := &http.Client{}
|
||||
req, err := http.NewRequest("GET", service.LogoURL, nil)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Failed to create HTTP request")
|
||||
log.Error().Err(err).Msg("GetPicture: Failed to create HTTP request")
|
||||
return
|
||||
}
|
||||
|
||||
@ -74,7 +71,7 @@ func (s *Server) handleApiPicture(c iris.Context) {
|
||||
req.Header.Set("Referer", service.Urls[0])
|
||||
resp, err := client.Do(req)
|
||||
if err != nil || resp.StatusCode != http.StatusOK {
|
||||
log.Error().Err(err).Msg("Could not get image")
|
||||
log.Error().Err(err).Msgf("GetPicture: Could not get image for %s", service.Name)
|
||||
respondWithPlaceholder(c, service.Name)
|
||||
return
|
||||
}
|
||||
@ -82,13 +79,13 @@ func (s *Server) handleApiPicture(c iris.Context) {
|
||||
|
||||
bodyBytes, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Could not read response body")
|
||||
log.Error().Err(err).Msgf("GetPicture: Could not read response body for %s", service.Name)
|
||||
respondWithPlaceholder(c, service.Name)
|
||||
return
|
||||
}
|
||||
|
||||
if bodyBytes == nil {
|
||||
log.Error().Msg("Could not read response body")
|
||||
log.Error().Msg("GetPicture: Could not read response body")
|
||||
respondWithPlaceholder(c, service.Name)
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user