From 97975f7ed45b37bc671e07e4721096e84fa1ea0a Mon Sep 17 00:00:00 2001 From: Shanoah Alkire Date: Sat, 11 Oct 2025 23:19:34 -0700 Subject: [PATCH] Tweak logging. Add new setting dialog. --- __init__.py | 15 ++++++----- js/sidebar/cacheSidebar.js | 51 +++++++++++++++++++++++++++++++++++++- nodes/loader.py | 8 +++--- routes/__init__.py | 3 +-- utils/path_manager.py | 2 +- 5 files changed, 65 insertions(+), 14 deletions(-) diff --git a/__init__.py b/__init__.py index 0b27209..a585db9 100644 --- a/__init__.py +++ b/__init__.py @@ -1,4 +1,13 @@ import os +import logging + +# Uncomment the next line to enable debug logging +# logging.basicConfig(level=logging.DEBUG) + +# Set to 1 for v1 nodes, 3 for v3 nodes. +# Right now, v3 nodes aren't ready for use. +CURRENT_NODE_VERSION = '1' +NODE_VERSION = os.environ.get('SAGEUTILS_NODE_VERSION', CURRENT_NODE_VERSION) SAGEUTILS_PRINT_TIMING = False # Set to True to enable timing report # Print timing report if enabled via environment variable @@ -9,11 +18,6 @@ if os.environ.get('SAGEUTILS_PRINT_TIMING', '').lower() in ('1', 'true', 'yes'): from .utils.performance_timer import python_timer, log_init log_init("IMPORTS_START") -# Set to 1 for v1 nodes, 3 for v3 nodes. -# Right now, v3 nodes aren't ready for use. -CURRENT_NODE_VERSION = '1' -NODE_VERSION = os.environ.get('SAGEUTILS_NODE_VERSION', CURRENT_NODE_VERSION) - # Import all node classes if NODE_VERSION == '1': from .nodes_v1 import * @@ -103,7 +107,6 @@ try: from .utils.performance_fix import populate_llm_cache_async populate_llm_cache_async() except Exception as e: - import logging logging.warning(f"Warning: Failed to start background LLM cache population: {e}") # Print timing report if enabled. diff --git a/js/sidebar/cacheSidebar.js b/js/sidebar/cacheSidebar.js index fcde5dd..f71a603 100644 --- a/js/sidebar/cacheSidebar.js +++ b/js/sidebar/cacheSidebar.js @@ -56,6 +56,7 @@ function createTabHeader() { background: #1a1a1a; overflow-x: auto; min-height: 50px; + position: relative; `; const modelsTab = createTabButton('Models', true); @@ -80,6 +81,53 @@ function createTabHeader() { tabHeader.appendChild(promptBuilderTab); tabHeader.appendChild(llmTab); + // Create settings gear button + const settingsButton = document.createElement('button'); + settingsButton.innerHTML = '⚙️'; + settingsButton.title = 'Settings'; + settingsButton.className = 'sidebar-settings-button'; + settingsButton.style.cssText = ` + position: absolute; + right: 10px; + top: 50%; + transform: translateY(-50%); + background: #2a2a2a; + border: 1px solid #444; + border-radius: 4px; + color: #ccc; + padding: 6px 10px; + cursor: pointer; + font-size: 18px; + transition: all 0.2s ease; + z-index: 10; + `; + + // Hover effect + settingsButton.addEventListener('mouseenter', () => { + settingsButton.style.background = '#4CAF50'; + settingsButton.style.borderColor = '#4CAF50'; + settingsButton.style.transform = 'translateY(-50%) scale(1.1)'; + }); + + settingsButton.addEventListener('mouseleave', () => { + settingsButton.style.background = '#2a2a2a'; + settingsButton.style.borderColor = '#444'; + settingsButton.style.transform = 'translateY(-50%) scale(1)'; + }); + + // Click handler - will be set up after import + settingsButton.addEventListener('click', async () => { + try { + const { showSettingsDialog } = await import('../dialogs/settingsDialog.js'); + showSettingsDialog(); + } catch (error) { + console.error('Failed to open settings dialog:', error); + handleError(error, 'Settings Dialog Error'); + } + }); + + tabHeader.appendChild(settingsButton); + return { tabHeader, modelsTab, @@ -87,7 +135,8 @@ function createTabHeader() { civitaiTab, galleryTab, promptBuilderTab, - llmTab + llmTab, + settingsButton }; } diff --git a/nodes/loader.py b/nodes/loader.py index bfa6577..4972513 100644 --- a/nodes/loader.py +++ b/nodes/loader.py @@ -47,7 +47,7 @@ class Sage_UNETLoaderFromInfo(ComfyNodeABC): def load_unet(self, unet_info): """Load UNET from model info.""" - logging.info("Loading UNET...") + #logging.info("Loading UNET...") graph = GraphBuilder() unet_node = add_unet_node_from_info(graph, unet_info) if unet_node is None: @@ -87,7 +87,7 @@ class Sage_CLIPLoaderFromInfo(ComfyNodeABC): def load_clip(self, clip_info): """Load CLIP from model info.""" - logging.info("Loading CLIP...") + #logging.info("Loading CLIP...") graph = GraphBuilder() clip_node = add_clip_node_from_info(graph, clip_info) if clip_node is None: @@ -127,7 +127,7 @@ class Sage_ChromaCLIPLoaderFromInfo(ComfyNodeABC): def load_clip(self, clip_info): """Load Chroma CLIP from model info.""" - logging.info("Loading CLIP...") + #logging.info("Loading CLIP...") graph = GraphBuilder() clip_node = add_clip_node_from_info(graph, clip_info) if clip_node is None: @@ -166,7 +166,7 @@ class Sage_VAELoaderFromInfo(ComfyNodeABC): def load_vae(self, vae_info): """Load VAE from model info.""" - logging.info("Loading VAE...") + #logging.info("Loading VAE...") graph = GraphBuilder() vae_node = add_vae_node_from_info(graph, vae_info) if vae_node is None: diff --git a/routes/__init__.py b/routes/__init__.py index 5925cc8..8388443 100644 --- a/routes/__init__.py +++ b/routes/__init__.py @@ -62,8 +62,7 @@ def register_routes(routes_instance): if hasattr(route_module, 'register_routes'): group_count = route_module.register_routes(routes_instance) route_count += group_count - logging.info(f"{group_name} routes registered successfully") - logging.info(f"Registered {group_count} {group_name} routes") + logging.debug(f"Registered {group_count} {group_name} routes successfully") _registered_routes.extend(route_module.get_route_list() if hasattr(route_module, 'get_route_list') else []) else: logging.warning(f"Route module {group_name} missing register_routes function") diff --git a/utils/path_manager.py b/utils/path_manager.py index 5d31c19..3090e82 100644 --- a/utils/path_manager.py +++ b/utils/path_manager.py @@ -126,7 +126,7 @@ class SageFileManager: data = self.load_json_file(path, f"{config_name} config") if data is not None: configs.append(data) - print(f"Loading {config_name} from {path}") + #print(f"Loading {config_name} from {path}") if not configs: return {}