Sfoglia il codice sorgente

Update JellyStat debug logging to use Organizr's native logging system

- Replace error_log() calls with ->writeLog('debug', ...)
- Improves log accessibility through Organizr's admin interface
- Provides consistent logging across the application
- Enables better log level management and filtering
mgomon 11 mesi fa
parent
commit
0e9f37e046
1 ha cambiato i file con 12 aggiunte e 7 eliminazioni
  1. 12 7
      api/homepage/jellystat.php

+ 12 - 7
api/homepage/jellystat.php

@@ -1049,8 +1049,8 @@ trait JellyStatHomepageItem
                         $actualItemId = $result['NowPlayingItemId'] ?? null;
                     } elseif ($contentType === 'show') {
                         // Debug: Log all available IDs for TV shows to understand data structure
-                        error_log("JellyStat TV Show Debug - Series: {$result['SeriesName']}");
-                        error_log("Available IDs: SeriesId=" . ($result['SeriesId'] ?? 'null') . 
+                        $this->writeLog('debug', "JellyStat TV Show Debug - Series: {$result['SeriesName']}");
+                        $this->writeLog('debug', "Available IDs: SeriesId=" . ($result['SeriesId'] ?? 'null') . 
                                  ", ShowId=" . ($result['ShowId'] ?? 'null') . 
                                  ", ParentId=" . ($result['ParentId'] ?? 'null') . 
                                  ", NowPlayingItemId=" . ($result['NowPlayingItemId'] ?? 'null'));
@@ -1062,23 +1062,23 @@ trait JellyStatHomepageItem
                         if (!empty($result['SeriesId'])) {
                             // SeriesId is the most reliable for series posters
                             $actualItemId = $result['SeriesId'];
-                            error_log("Using SeriesId: {$actualItemId}");
+                            $this->writeLog('debug', "Using SeriesId: {$actualItemId}");
                         } elseif (!empty($result['ShowId'])) {
                             // ShowId is also series-specific
                             $actualItemId = $result['ShowId'];
-                            error_log("Using ShowId: {$actualItemId}");
+                            $this->writeLog('debug', "Using ShowId: {$actualItemId}");
                         } elseif (!empty($result['NowPlayingItemId'])) {
                             // Try NowPlayingItemId - it might be the series ID if we're looking at series-level data
                             $actualItemId = $result['NowPlayingItemId'];
-                            error_log("Using NowPlayingItemId: {$actualItemId}");
+                            $this->writeLog('debug', "Using NowPlayingItemId: {$actualItemId}");
                         } elseif (!empty($result['ParentId'])) {
                             // Last resort: ParentId (might be series, season, or library)
                             $actualItemId = $result['ParentId'];
-                            error_log("Using ParentId: {$actualItemId}");
+                            $this->writeLog('debug', "Using ParentId: {$actualItemId}");
                         }
                         
                         if (!$actualItemId) {
-                            error_log("No suitable ID found for TV show: {$result['SeriesName']}");
+                            $this->writeLog('debug', "No suitable ID found for TV show: {$result['SeriesName']}");
                         }
                     } elseif ($contentType === 'music') {
                         // For music, use NowPlayingItemId (album/track)
@@ -1102,6 +1102,11 @@ trait JellyStatHomepageItem
                 $itemStats[$key]['play_count']++;
                 $itemStats[$key]['total_duration'] += $result['PlaybackDuration'] ?? 0;
                 
+                // Debug: Log each play count increment
+                if ($contentType === 'show') {
+                    $this->writeLog('debug', "Play count increment for {$title}: now {$itemStats[$key]['play_count']} (Episode: {$result['EpisodeName']}, User: {$result['UserName']}, Date: {$result['ActivityDateInserted']})");
+                }
+                
                 // Update last played time
                 $currentTime = $result['ActivityDateInserted'] ?? null;
                 if ($currentTime && (!$itemStats[$key]['last_played'] || $currentTime > $itemStats[$key]['last_played'])) {