refactor: remove noisy debug logging
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -257,7 +256,6 @@ func (c *Client) getWithCache(ctx context.Context, cacheKey string, ttl time.Dur
|
|||||||
if !isEmptyResult(out) {
|
if !isEmptyResult(out) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
log.Printf("jikan: cache hit for %s but data is empty, refetching", cacheKey)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var stale any
|
var stale any
|
||||||
@@ -273,7 +271,6 @@ func (c *Client) getWithCache(ctx context.Context, cacheKey string, ttl time.Dur
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !errors.Is(err, context.Canceled) {
|
if !errors.Is(err, context.Canceled) {
|
||||||
log.Printf("jikan: stale cache unmarshal failed or empty, falling back to error: %v", err)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
@@ -281,7 +278,6 @@ func (c *Client) getWithCache(ctx context.Context, cacheKey string, ttl time.Dur
|
|||||||
|
|
||||||
// Don't cache empty results to avoid caching failures
|
// Don't cache empty results to avoid caching failures
|
||||||
if isEmptyResult(out) {
|
if isEmptyResult(out) {
|
||||||
log.Printf("jikan: fetched data for %s is empty, not caching", cacheKey)
|
|
||||||
return fmt.Errorf("jikan: empty response for %s", cacheKey)
|
return fmt.Errorf("jikan: empty response for %s", cacheKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -143,7 +143,6 @@ func (c *Client) GetFullRelations(ctx context.Context, id int) ([]RelationEntry,
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
c.EnqueueAnimeFetchRetry(gCtx, entry.ID, err)
|
c.EnqueueAnimeFetchRetry(gCtx, entry.ID, err)
|
||||||
log.Printf("relations: skipping related anime %d for root %d: %v", entry.ID, id, err)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package handler
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"mal/internal/domain"
|
"mal/internal/domain"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -23,7 +22,7 @@ func NewAnimeHandler(svc domain.AnimeService, watchlistSvc domain.WatchlistServi
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *AnimeHandler) Register(r *gin.Engine) {
|
func (h *AnimeHandler) Register(r *gin.Engine) {
|
||||||
log.Println("Registering anime routes")
|
|
||||||
r.GET("/", h.HandleCatalog)
|
r.GET("/", h.HandleCatalog)
|
||||||
r.GET("/api/catalog/airing", h.HandleCatalogAiring)
|
r.GET("/api/catalog/airing", h.HandleCatalogAiring)
|
||||||
r.GET("/api/catalog/popular", h.HandleCatalogPopular)
|
r.GET("/api/catalog/popular", h.HandleCatalogPopular)
|
||||||
@@ -76,7 +75,6 @@ func (h *AnimeHandler) renderCatalogSection(c *gin.Context, section string) {
|
|||||||
}
|
}
|
||||||
data, err := h.svc.GetCatalogSection(c.Request.Context(), userID, section)
|
data, err := h.svc.GetCatalogSection(c.Request.Context(), userID, section)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("catalog %s error: %v", section, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +120,6 @@ func (h *AnimeHandler) renderDiscoverSection(c *gin.Context, section string) {
|
|||||||
}
|
}
|
||||||
data, err := h.svc.GetDiscoverSection(c.Request.Context(), userID, section)
|
data, err := h.svc.GetDiscoverSection(c.Request.Context(), userID, section)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("discover %s error: %v", section, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +160,6 @@ func (h *AnimeHandler) HandleBrowse(c *gin.Context) {
|
|||||||
|
|
||||||
res, err := h.svc.SearchAdvanced(c.Request.Context(), q, animeType, status, orderBy, sort, genres, sfw, page, 24)
|
res, err := h.svc.SearchAdvanced(c.Request.Context(), q, animeType, status, orderBy, sort, genres, sfw, page, 24)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("browse error: %v", err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
user, _ := c.Get("User")
|
user, _ := c.Get("User")
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package handler
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
|
||||||
"mal/internal/domain"
|
"mal/internal/domain"
|
||||||
"mal/pkg/net/proxytransport"
|
"mal/pkg/net/proxytransport"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -33,7 +32,7 @@ func NewPlaybackHandler(svc domain.PlaybackService, animeSvc domain.AnimeService
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *PlaybackHandler) Register(r *gin.Engine) {
|
func (h *PlaybackHandler) Register(r *gin.Engine) {
|
||||||
log.Println("Registering playback routes")
|
|
||||||
r.GET("/anime/:id/watch", h.HandleWatchPage)
|
r.GET("/anime/:id/watch", h.HandleWatchPage)
|
||||||
r.POST("/api/watch-progress", h.HandleSaveProgress)
|
r.POST("/api/watch-progress", h.HandleSaveProgress)
|
||||||
r.POST("/api/watch-complete", h.HandleWatchComplete)
|
r.POST("/api/watch-complete", h.HandleWatchComplete)
|
||||||
@@ -43,7 +42,6 @@ func (h *PlaybackHandler) Register(r *gin.Engine) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *PlaybackHandler) HandleWatchPage(c *gin.Context) {
|
func (h *PlaybackHandler) HandleWatchPage(c *gin.Context) {
|
||||||
log.Printf("Route /anime/:id/watch triggered for ID: %s", c.Param("id"))
|
|
||||||
id, _ := strconv.Atoi(c.Param("id"))
|
id, _ := strconv.Atoi(c.Param("id"))
|
||||||
ep := c.DefaultQuery("ep", "1")
|
ep := c.DefaultQuery("ep", "1")
|
||||||
mode := c.DefaultQuery("mode", "sub")
|
mode := c.DefaultQuery("mode", "sub")
|
||||||
@@ -56,8 +54,6 @@ func (h *PlaybackHandler) HandleWatchPage(c *gin.Context) {
|
|||||||
|
|
||||||
data, err := h.svc.BuildWatchData(c.Request.Context(), id, []string{}, ep, mode, userID)
|
data, err := h.svc.BuildWatchData(c.Request.Context(), id, []string{}, ep, mode, userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("BuildWatchData failed for ID %d: %v", id, err)
|
|
||||||
// Try to at least get anime info for the error page
|
|
||||||
anime, _ := h.animeSvc.GetAnimeByID(c.Request.Context(), id)
|
anime, _ := h.animeSvc.GetAnimeByID(c.Request.Context(), id)
|
||||||
c.HTML(http.StatusOK, "watch.gohtml", gin.H{
|
c.HTML(http.StatusOK, "watch.gohtml", gin.H{
|
||||||
"Error": err.Error(),
|
"Error": err.Error(),
|
||||||
@@ -70,7 +66,6 @@ func (h *PlaybackHandler) HandleWatchPage(c *gin.Context) {
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Printf("BuildWatchData succeeded for ID %d", id)
|
|
||||||
|
|
||||||
// Merge data from service with handler-specific context
|
// Merge data from service with handler-specific context
|
||||||
responseData := gin.H{
|
responseData := gin.H{
|
||||||
@@ -82,7 +77,6 @@ func (h *PlaybackHandler) HandleWatchPage(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
c.HTML(http.StatusOK, "watch.gohtml", responseData)
|
c.HTML(http.StatusOK, "watch.gohtml", responseData)
|
||||||
log.Printf("c.HTML finished for ID %d", id)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *PlaybackHandler) HandleSaveProgress(c *gin.Context) {
|
func (h *PlaybackHandler) HandleSaveProgress(c *gin.Context) {
|
||||||
@@ -147,7 +141,6 @@ func (h *PlaybackHandler) HandleEpisodeThumbnails(c *gin.Context) {
|
|||||||
|
|
||||||
allEpisodes, err := h.animeSvc.GetAllEpisodes(c.Request.Context(), id)
|
allEpisodes, err := h.animeSvc.GetAllEpisodes(c.Request.Context(), id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("failed to fetch thumbnails/episodes: %v", err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
anime, _ := h.animeSvc.GetAnimeByID(c.Request.Context(), id)
|
anime, _ := h.animeSvc.GetAnimeByID(c.Request.Context(), id)
|
||||||
@@ -195,7 +188,6 @@ func (h *PlaybackHandler) HandleProxyStream(c *gin.Context) {
|
|||||||
|
|
||||||
targetURL, referer, err := h.svc.ResolveProxyToken(token)
|
targetURL, referer, err := h.svc.ResolveProxyToken(token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("proxy token error: %v", err)
|
|
||||||
c.Status(http.StatusForbidden)
|
c.Status(http.StatusForbidden)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -212,7 +204,6 @@ func (h *PlaybackHandler) HandleProxyStream(c *gin.Context) {
|
|||||||
|
|
||||||
resp, err := h.streamingClient.Do(req)
|
resp, err := h.streamingClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("proxy stream fetch error: %v", err)
|
|
||||||
c.Status(http.StatusBadGateway)
|
c.Status(http.StatusBadGateway)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -239,7 +230,6 @@ func (h *PlaybackHandler) HandleProxySubtitle(c *gin.Context) {
|
|||||||
|
|
||||||
targetURL, referer, err := h.svc.ResolveProxyToken(token)
|
targetURL, referer, err := h.svc.ResolveProxyToken(token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("proxy subtitle token error: %v", err)
|
|
||||||
c.Status(http.StatusForbidden)
|
c.Status(http.StatusForbidden)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -262,7 +252,6 @@ func (h *PlaybackHandler) HandleProxySubtitle(c *gin.Context) {
|
|||||||
|
|
||||||
resp, err := h.proxyClient.Do(req)
|
resp, err := h.proxyClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("proxy subtitle fetch error: %v", err)
|
|
||||||
c.Status(http.StatusBadGateway)
|
c.Status(http.StatusBadGateway)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -270,7 +259,6 @@ func (h *PlaybackHandler) HandleProxySubtitle(c *gin.Context) {
|
|||||||
|
|
||||||
body, err := io.ReadAll(io.LimitReader(resp.Body, 2*1024*1024))
|
body, err := io.ReadAll(io.LimitReader(resp.Body, 2*1024*1024))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("proxy subtitle read error: %v", err)
|
|
||||||
c.Status(http.StatusBadGateway)
|
c.Status(http.StatusBadGateway)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
|
||||||
"mal/integrations/jikan"
|
"mal/integrations/jikan"
|
||||||
"mal/internal/db"
|
"mal/internal/db"
|
||||||
"mal/internal/domain"
|
"mal/internal/domain"
|
||||||
@@ -217,7 +216,6 @@ func (s *playbackService) BuildWatchData(ctx context.Context, animeID int, title
|
|||||||
// 4. Get Episodes list
|
// 4. Get Episodes list
|
||||||
jikanEpisodes, err := s.jikan.GetAllEpisodes(ctx, animeID)
|
jikanEpisodes, err := s.jikan.GetAllEpisodes(ctx, animeID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("failed to fetch episodes from jikan: %v", err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback/Fill episodes if needed
|
// Fallback/Fill episodes if needed
|
||||||
|
|||||||
Reference in New Issue
Block a user