refactor(src/shared): replace print statements with logger.error
Use centralized logging instead of stdout prints to improve observability and consistency
This commit is contained in:
6 files changed
+26
-20
No files matched your search
+2
-1
@@ -1,3 +1,4 @@
|
|||||||
|
from fabric.utils import logger
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from fabric.utils import Gdk, GLib, get_relative_path, os
|
from fabric.utils import Gdk, GLib, get_relative_path, os
|
||||||
@@ -41,7 +42,7 @@ def load_config():
|
|||||||
with open(CONFIG_FILE, "r") as f:
|
with open(CONFIG_FILE, "r") as f:
|
||||||
config = json.load(f)
|
config = json.load(f)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error loading config: {e}")
|
logger.error(f"Error loading config: {e}")
|
||||||
|
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from fabric.utils import GdkPixbuf, Gtk, get_relative_path, os, re
|
from fabric.utils import GdkPixbuf, Gtk, get_relative_path, os, re, logger
|
||||||
|
|
||||||
from utils.functions import escape_markup_text
|
from utils.functions import escape_markup_text
|
||||||
from utils.icon_resolver import IconResolver
|
from utils.icon_resolver import IconResolver
|
||||||
@@ -73,8 +73,8 @@ def get_executable_path(exec_string):
|
|||||||
result = subprocess.run(["which", executable], capture_output=True, text=True)
|
result = subprocess.run(["which", executable], capture_output=True, text=True)
|
||||||
if result.returncode == 0:
|
if result.returncode == 0:
|
||||||
return result.stdout.strip()
|
return result.stdout.strip()
|
||||||
except Exception:
|
except Exception as e:
|
||||||
pass
|
logger.error(f"An error occurred: {e}")
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -212,8 +212,8 @@ def get_app_info(wmclass):
|
|||||||
)
|
)
|
||||||
if result.returncode == 0:
|
if result.returncode == 0:
|
||||||
location = result.stdout.strip()
|
location = result.stdout.strip()
|
||||||
except Exception:
|
except Exception as e:
|
||||||
pass
|
logger.error(f"An error occurred: {e}")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"name": wmclass.title() if wmclass else "Unknown Application",
|
"name": wmclass.title() if wmclass else "Unknown Application",
|
||||||
@@ -261,8 +261,8 @@ class AboutApp(Gtk.Window):
|
|||||||
icon_pixbuf = self.icon_resolver.get_icon_pixbuf(app_info["icon"], 128)
|
icon_pixbuf = self.icon_resolver.get_icon_pixbuf(app_info["icon"], 128)
|
||||||
if icon_pixbuf:
|
if icon_pixbuf:
|
||||||
logo = Gtk.Image.new_from_pixbuf(icon_pixbuf)
|
logo = Gtk.Image.new_from_pixbuf(icon_pixbuf)
|
||||||
except Exception:
|
except Exception as e:
|
||||||
pass
|
logger.error(f"An error occurred: {e}")
|
||||||
|
|
||||||
if not logo:
|
if not logo:
|
||||||
try:
|
try:
|
||||||
@@ -273,8 +273,8 @@ class AboutApp(Gtk.Window):
|
|||||||
icon_path, 128, 128, True
|
icon_path, 128, 128, True
|
||||||
)
|
)
|
||||||
logo = Gtk.Image.new_from_pixbuf(pixbuf)
|
logo = Gtk.Image.new_from_pixbuf(pixbuf)
|
||||||
except Exception:
|
except Exception as e:
|
||||||
pass
|
logger.error(f"An error occurred: {e}")
|
||||||
|
|
||||||
if not logo:
|
if not logo:
|
||||||
# 3. Final fallback
|
# 3. Final fallback
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
from fabric.utils import logger
|
||||||
from fabric.utils import GLib
|
from fabric.utils import GLib
|
||||||
from fabric.widgets.eventbox import EventBox # noqa: E402
|
from fabric.widgets.eventbox import EventBox # noqa: E402
|
||||||
from fabric.widgets.wayland import WaylandWindow as Window # noqa: E402
|
from fabric.widgets.wayland import WaylandWindow as Window # noqa: E402
|
||||||
@@ -51,7 +52,9 @@ class AppletWindow(PopupWindow):
|
|||||||
else:
|
else:
|
||||||
active.hide()
|
active.hide()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"[AppletWindow] Warning: failed to close active popup: {e}")
|
logger.error(
|
||||||
|
f"[AppletWindow] Warning: failed to close active popup: {e}"
|
||||||
|
)
|
||||||
|
|
||||||
AppletWindow._active_popup = self
|
AppletWindow._active_popup = self
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
from fabric.utils import logger
|
||||||
from fabric.utils import GLib
|
from fabric.utils import GLib
|
||||||
from fabric.widgets.box import Box
|
from fabric.widgets.box import Box
|
||||||
from fabric.widgets.button import Button
|
from fabric.widgets.button import Button
|
||||||
@@ -125,7 +126,7 @@ class GameModeButton(Box):
|
|||||||
toggle_gamemode()
|
toggle_gamemode()
|
||||||
GLib.timeout_add(500, lambda: self.update_state())
|
GLib.timeout_add(500, lambda: self.update_state())
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Failed to toggle game mode: {e}")
|
logger.error(f"Failed to toggle game mode: {e}")
|
||||||
|
|
||||||
GLib.timeout_add(300, lambda: self._reset_icon_state())
|
GLib.timeout_add(300, lambda: self._reset_icon_state())
|
||||||
|
|
||||||
@@ -140,7 +141,7 @@ class GameModeButton(Box):
|
|||||||
else:
|
else:
|
||||||
self.game_icon.remove_style_class("connected")
|
self.game_icon.remove_style_class("connected")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Failed to check game mode status: {e}")
|
logger.error(f"Failed to check game mode status: {e}")
|
||||||
self.game_icon.remove_style_class("connected")
|
self.game_icon.remove_style_class("connected")
|
||||||
|
|
||||||
return False # Remove timeout if called from GLib.timeout_add
|
return False # Remove timeout if called from GLib.timeout_add
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
from fabric.utils import logger
|
||||||
from fabric.widgets.box import Box
|
from fabric.widgets.box import Box
|
||||||
from fabric.widgets.centerbox import CenterBox
|
from fabric.widgets.centerbox import CenterBox
|
||||||
from fabric.widgets.eventbox import EventBox
|
from fabric.widgets.eventbox import EventBox
|
||||||
@@ -87,7 +88,7 @@ class ModusDropdown(AppletWindow):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
modus_service.disconnect_by_func(self.hide_dropdown)
|
modus_service.disconnect_by_func(self.hide_dropdown)
|
||||||
except Exception:
|
except Exception as e:
|
||||||
pass
|
logger.error(f"An error occurred: {e}")
|
||||||
|
|
||||||
super().destroy()
|
super().destroy()
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
from fabric.utils import Gdk, GLib, Gtk
|
from fabric.utils import Gdk, GLib, Gtk, logger
|
||||||
from fabric.widgets.wayland import WaylandWindow
|
from fabric.widgets.wayland import WaylandWindow
|
||||||
from gi.repository import GtkLayerShell
|
from gi.repository import GtkLayerShell
|
||||||
|
|
||||||
@@ -51,8 +51,8 @@ class PopupWindow(WaylandWindow):
|
|||||||
if self._pointing_widget:
|
if self._pointing_widget:
|
||||||
try:
|
try:
|
||||||
self._pointing_widget.disconnect_by_func(self.do_handle_size_allocate)
|
self._pointing_widget.disconnect_by_func(self.do_handle_size_allocate)
|
||||||
except Exception:
|
except Exception as e:
|
||||||
pass
|
logger.error(f"An error occurred: {e}")
|
||||||
self._pointing_widget = widget
|
self._pointing_widget = widget
|
||||||
return self.do_update_handlers()
|
return self.do_update_handlers()
|
||||||
|
|
||||||
@@ -74,8 +74,8 @@ class PopupWindow(WaylandWindow):
|
|||||||
try:
|
try:
|
||||||
self._pointing_widget.disconnect_by_func(self.do_handle_size_allocate)
|
self._pointing_widget.disconnect_by_func(self.do_handle_size_allocate)
|
||||||
self.disconnect_by_func(self.do_handle_size_allocate)
|
self.disconnect_by_func(self.do_handle_size_allocate)
|
||||||
except Exception:
|
except Exception as e:
|
||||||
pass
|
logger.error(f"An error occurred: {e}")
|
||||||
return
|
return
|
||||||
|
|
||||||
self._pointing_widget.connect("size-allocate", self.do_handle_size_allocate)
|
self._pointing_widget.connect("size-allocate", self.do_handle_size_allocate)
|
||||||
|
|||||||
Reference in new issue
Block a user