feat: add version updater and statistics enhancements (fixes #29)
- Implemented version checking system with update notifications - Integrated Git for fetching and downloading the latest version - Added statistics updates - Removed unused code across the project - Condensed project structure - Updated README - Cleaned up UI
This commit is contained in:
+26
-3
@@ -83,7 +83,18 @@ def get_base_directory() -> Path:
|
||||
return home / ".local" / "share" / "Loxide"
|
||||
|
||||
|
||||
def configure_logging(log_dir: Path, log_level: str = "INFO"):
|
||||
def configure_logging(log_dir: Path, cache_dir: Path, log_level: str = "INFO"):
|
||||
"""
|
||||
Configure logging and return function to attach notification handler.
|
||||
|
||||
Args:
|
||||
log_dir: Directory for log files
|
||||
cache_dir: Directory for cache files (used by version checker)
|
||||
log_level: Logging level string
|
||||
|
||||
Returns:
|
||||
Function to attach notification handler to Textual app
|
||||
"""
|
||||
log_file = log_dir / "Loxide.log"
|
||||
|
||||
config = {
|
||||
@@ -134,7 +145,8 @@ def configure_logging(log_dir: Path, log_level: str = "INFO"):
|
||||
|
||||
# Return a function to attach the notification handler once the app is created
|
||||
def attach_notification_handler(app):
|
||||
"""Attach the Textual notification handler to the root logger."""
|
||||
"""Attach the Textual notification handler and version checker to the app."""
|
||||
# Attach logging handler
|
||||
handler = TextualNotificationHandler(app)
|
||||
handler.setLevel(logging.WARNING) # Only WARNING and above
|
||||
formatter = logging.Formatter("%(name)s: %(message)s")
|
||||
@@ -142,6 +154,17 @@ def configure_logging(log_dir: Path, log_level: str = "INFO"):
|
||||
logging.getLogger().addHandler(handler)
|
||||
logging.getLogger().debug("✅ Textual notification handler attached.")
|
||||
|
||||
# Attach version checker (checks in background, notifies if update available)
|
||||
try:
|
||||
from utils.versionchecker import create_update_notifier
|
||||
|
||||
create_update_notifier(app, cache_dir=cache_dir)
|
||||
logging.getLogger().debug("✅ Version checker attached.")
|
||||
except ImportError as e:
|
||||
logging.getLogger().debug(f"Version checker not available: {e}")
|
||||
except Exception as e:
|
||||
logging.getLogger().warning(f"Could not initialize version checker: {e}")
|
||||
|
||||
return attach_notification_handler
|
||||
|
||||
|
||||
@@ -173,7 +196,7 @@ def setup():
|
||||
|
||||
# Configure logging with system-defined log level
|
||||
log_level = get_system_value("LOG_LEVEL", str, "INFO")
|
||||
attach_handler = configure_logging(dirs["logs"], log_level)
|
||||
attach_handler = configure_logging(dirs["logs"], dirs["cache"], log_level)
|
||||
|
||||
# Load user config (mutable)
|
||||
load_user_config(dirs["config"])
|
||||
|
||||
Reference in New Issue
Block a user