From 6d8e7abff76317b50427f49c215c8a2b9c370cdc Mon Sep 17 00:00:00 2001 From: Chuck <33324927+ChuckBuilds@users.noreply.github.com> Date: Sun, 27 Jul 2025 10:14:55 -0500 Subject: [PATCH] reduce dynamic duration logging --- src/display_controller.py | 17 ++++++++++++++++- src/news_manager.py | 10 +++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/display_controller.py b/src/display_controller.py index 25106386..715804bd 100644 --- a/src/display_controller.py +++ b/src/display_controller.py @@ -296,6 +296,9 @@ class DisplayController: # Set initial display to first available mode (clock) self.current_mode_index = 0 self.current_display_mode = self.available_modes[0] if self.available_modes else 'none' + # Reset logged duration when mode is initialized + if hasattr(self, '_last_logged_duration'): + delattr(self, '_last_logged_duration') self.last_switch = time.time() self.force_clear = True self.update_interval = 0.01 # Reduced from 0.1 to 0.01 for smoother scrolling @@ -447,7 +450,10 @@ class DisplayController: if mode_key == 'news_manager' and self.news_manager: try: dynamic_duration = self.news_manager.get_dynamic_duration() - logger.info(f"Using dynamic duration for news_manager: {dynamic_duration} seconds") + # Only log if duration has changed or we haven't logged this duration yet + if not hasattr(self, '_last_logged_duration') or self._last_logged_duration != dynamic_duration: + logger.info(f"Using dynamic duration for news_manager: {dynamic_duration} seconds") + self._last_logged_duration = dynamic_duration return dynamic_duration except Exception as e: logger.error(f"Error getting dynamic duration for news_manager: {e}") @@ -853,6 +859,9 @@ class DisplayController: if self.current_display_mode != new_mode: logger.info(f"Switching to only active live sport: {new_mode} from {self.current_display_mode}") self.current_display_mode = new_mode + # Reset logged duration when mode changes + if hasattr(self, '_last_logged_duration'): + delattr(self, '_last_logged_duration') self.force_clear = True else: self.force_clear = False @@ -873,6 +882,9 @@ class DisplayController: if previous_mode_before_switch == 'music' and self.music_manager: self.music_manager.deactivate_music_display() self.current_display_mode = new_mode + # Reset logged duration when mode changes + if hasattr(self, '_last_logged_duration'): + delattr(self, '_last_logged_duration') self.force_clear = True self.last_switch = current_time manager_to_display = getattr(self, f"{live_priority_sport}_live", None) @@ -896,6 +908,9 @@ class DisplayController: if previous_mode_before_switch == 'music' and self.music_manager and new_mode_after_timer != 'music': self.music_manager.deactivate_music_display() self.current_display_mode = new_mode_after_timer + # Reset logged duration when mode changes + if hasattr(self, '_last_logged_duration'): + delattr(self, '_last_logged_duration') if needs_switch: self.force_clear = True self.last_switch = current_time diff --git a/src/news_manager.py b/src/news_manager.py index 31fd0b3c..dd89c5a6 100644 --- a/src/news_manager.py +++ b/src/news_manager.py @@ -173,7 +173,7 @@ class NewsManager: self.prepare_headlines_for_display() self.last_update = time.time() - logger.info(f"Fetched {len(all_headlines)} total headlines from {len(self.enabled_feeds)} feeds") + logger.debug(f"Fetched {len(all_headlines)} total headlines from {len(self.enabled_feeds)} feeds") except Exception as e: logger.error(f"Error fetching news data: {e}") @@ -216,7 +216,7 @@ class NewsManager: self.calculate_scroll_dimensions() self.current_headlines = display_headlines - logger.info(f"Prepared {len(display_headlines)} headlines for display") + logger.debug(f"Prepared {len(display_headlines)} headlines for display") def calculate_scroll_dimensions(self): """Calculate exact dimensions needed for smooth scrolling""" @@ -241,8 +241,8 @@ class NewsManager: # Calculate dynamic display duration self.calculate_dynamic_duration() - logger.info(f"Text width calculated: {self.total_scroll_width} pixels") - logger.info(f"Dynamic duration calculated: {self.dynamic_duration} seconds") + logger.debug(f"Text width calculated: {self.total_scroll_width} pixels") + logger.debug(f"Dynamic duration calculated: {self.dynamic_duration} seconds") except Exception as e: logger.error(f"Error calculating scroll dimensions: {e}") @@ -254,7 +254,7 @@ class NewsManager: # If dynamic duration is disabled, use fixed duration from config if not self.dynamic_duration_enabled: self.dynamic_duration = self.news_config.get('fixed_duration', 60) - logger.info(f"Dynamic duration disabled, using fixed duration: {self.dynamic_duration}s") + logger.debug(f"Dynamic duration disabled, using fixed duration: {self.dynamic_duration}s") return if not self.total_scroll_width: