feat(src/utils): replace printwith logger.error for consistent error logging

Use logger.error across utils to centralize error handling and allow configurable logging levels.
This commit is contained in:
sankalp committed 2026-06-17 05:21:19 +05:45
1 parent 1aed6ea816
commit 420688e9a7
4 files changed
+15 -12

No files matched your search

+3 -2
View File
@@ -1,3 +1,4 @@
from fabric.utils import logger
import threading
import time
from concurrent.futures import ThreadPoolExecutor
@@ -99,7 +100,7 @@ class CurrencyCache:
"timestamp": current_time,
}
except Exception as je:
print(f"Failed to parse JSON for {from_code}: {je}")
logger.error(f"Failed to parse JSON for {from_code}: {je}")
else:
print(
f"Background fetch for {from_code} returned status {
@@ -108,7 +109,7 @@ class CurrencyCache:
)
except Exception as e:
print(f"Background currency fetch failed for {from_code}: {e}")
logger.error(f"Background currency fetch failed for {from_code}: {e}")
finally:
# Mark request as complete
with self._cache_lock:
+3 -3
View File
@@ -1,4 +1,4 @@
from fabric.utils import Gio, GLib
from fabric.utils import Gio, GLib, logger
class GioDBusHelper:
@@ -67,8 +67,8 @@ class GioDBusHelper:
"""Unsubscribe a previously registered signal using its subscription id."""
try:
self.bus.signal_unsubscribe(subscription_id)
except Exception:
pass
except Exception as e:
logger.error(f"An error occurred: {e}")
def set_property(self, interface_name, property_name, value_variant):
"""Sets a D-Bus property using the standard D-Bus Properties interface."""
+5 -4
View File
@@ -1,3 +1,4 @@
from fabric.utils import logger
# From https://github.com/stwa/wayland-idle-inhibitor
# License: WTFPL Version 2
@@ -78,10 +79,10 @@ def kill_existing_inhibit_processes():
except subprocess.CalledProcessError:
# No processes found
print("No existing inhibit processes were running")
logger.error("No existing inhibit processes were running")
return 0
except Exception as e:
print(f"Error stopping existing processes: {e}")
logger.error(f"Error stopping existing processes: {e}")
return 0
@@ -182,8 +183,8 @@ def main() -> None:
shutdown()
except Exception as e:
print(f"Error: {str(e)}")
print("Make sure you're running this under a Wayland session.")
logger.error(f"Error: {str(e)}")
logger.error("Make sure you're running this under a Wayland session.")
sys.exit(1)
+4 -3
View File
@@ -1,3 +1,4 @@
from fabric.utils import logger
import json
import subprocess
@@ -19,7 +20,7 @@ def get_current_workspace():
if part == "ID" and i + 1 < len(parts):
return int(parts[i + 1])
except Exception as e:
print(f"Error getting current workspace: {e}")
logger.error(f"Error getting current workspace: {e}")
return -1
@@ -53,7 +54,7 @@ def get_screen_dimensions():
"height", data.CURRENT_HEIGHT
)
except Exception as e:
print(f"Error getting screen dimensions: {e}")
logger.error(f"Error getting screen dimensions: {e}")
# Default fallback values
return data.CURRENT_WIDTH, data.CURRENT_HEIGHT
@@ -103,7 +104,7 @@ def check_occlusion(occlusion_region, workspace=None):
)
clients = json.loads(result.stdout)
except Exception as e:
print(f"Error retrieving client windows: {e}")
logger.error(f"Error retrieving client windows: {e}")
return False
occ_x, occ_y, occ_width, occ_height = occlusion_region