From ecf4ae6b15835a8a1cecd5ac4d0b9c3520bc11f4 Mon Sep 17 00:00:00 2001 From: Pedram Bakh <56321501+PedramBakh@users.noreply.github.com> Date: Fri, 20 Sep 2024 10:04:51 +0300 Subject: [PATCH] Display logging for generic CPU handler --- carbontracker/components/cpu/generic.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/carbontracker/components/cpu/generic.py b/carbontracker/components/cpu/generic.py index 6765739..1a8f040 100644 --- a/carbontracker/components/cpu/generic.py +++ b/carbontracker/components/cpu/generic.py @@ -20,7 +20,7 @@ def get_cpu_brand(self) -> str: try: info = cpuinfo.get_cpu_info() cpu_brand = info.get('brand_raw', '') - logger.info(f"Detected CPU: {cpu_brand}") + logger.err_info(f"Detected CPU: {cpu_brand}") return cpu_brand except Exception as e: logger.err_warn(f"Failed to get CPU info: {e}") @@ -60,12 +60,9 @@ def calculate_average_tdp(self) -> float: return statistics.mean(self.cpu_power_data.values()) / 2 # 50% utilization def init(self): - logger.info("[setup] CPU Tracking...") if not self.cpu_brand: logger.err_warn("Failed to detect CPU. Falling back to generic CPU handler.") self.cpu_brand = "Unknown CPU" - else: - logger.info(f"CPU Model: {self.cpu_brand}") self.tdp = self.find_matching_tdp() @@ -74,7 +71,7 @@ def init(self): logger.err_warn(f"No matching TDP found for CPU: {self.cpu_brand}. Using average TDP of {self.tdp:.2f}W as fallback.") else: self.tdp = self.tdp / 2 # 50% utilization - logger.info(f"Using TDP of {self.tdp:.2f}W for {self.cpu_brand}") + logger.err_info(f"Using TDP of {self.tdp:.2f}W for {self.cpu_brand}") def find_matching_tdp(self) -> Optional[float]: # Try direct match @@ -85,7 +82,7 @@ def find_matching_tdp(self) -> Optional[float]: cpu_name_without_freq = self.cpu_brand.split('@')[0].strip() for cpu_name, tdp in self.cpu_power_data.items(): if cpu_name_without_freq in cpu_name: - logger.info(f"Matched CPU {self.cpu_brand} to {cpu_name} with TDP {tdp}W") + logger.err_info(f"Matched CPU {self.cpu_brand} to {cpu_name} with TDP {tdp}W") return tdp return None