## New Directory Structure - utils/: Shared utilities (color_utils, shape_masks, noise_utils) - core/: Central logic (params, constants, blending, transforms, model_compat, sampler, debug, logging) - shaders/: Shader generators with BaseNoiseGenerator ABC and plugin registry - nodes/: ComfyUI node class definitions ## Key Changes - Centralized color interpolation logic eliminating duplication across shader files - Unified shape mask generation with 20+ shape types - Consolidated simplex/FBM/perlin noise implementations - Created ShaderParams class for parameter normalization and validation - Implemented ShaderRegistry for plugin-based shader registration - Extracted blending operations and noise transforms to dedicated modules - Added model compatibility layer for channel detection - Moved stub visualizer/debugger to core/debug.py - Added centralized logging configuration ## Refactored Shaders - domain_warp.py: Now uses shared utilities and BaseNoiseGenerator - tensor_field.py: Now uses shared utilities and BaseNoiseGenerator - curl_noise.py: Now uses shared utilities and BaseNoiseGenerator - temporal_coherent_noise.py: Now uses shared utilities and BaseNoiseGenerator ## Cleanup - Removed duplicate SHADER_GENERATORS registry - Added comprehensive type hints to all new modules - Maintained backward compatibility with legacy API
92 lines
2.2 KiB
Python
92 lines
2.2 KiB
Python
"""
|
|
Logging configuration for ComfyUI-ShaderNoiseKSampler.
|
|
|
|
This module provides centralized logging setup for the package.
|
|
"""
|
|
|
|
import logging
|
|
import sys
|
|
from typing import Optional
|
|
|
|
# Package-wide logger
|
|
PACKAGE_NAME = "comfyui_shader_noise"
|
|
|
|
# Default format
|
|
DEFAULT_FORMAT = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
|
|
SIMPLE_FORMAT = "[%(name)s] %(levelname)s: %(message)s"
|
|
|
|
|
|
def setup_logging(
|
|
level: int = logging.INFO,
|
|
format_string: Optional[str] = None,
|
|
handler: Optional[logging.Handler] = None
|
|
) -> logging.Logger:
|
|
"""
|
|
Set up logging for the package.
|
|
|
|
Args:
|
|
level: Logging level (default: INFO)
|
|
format_string: Log format string (default: SIMPLE_FORMAT)
|
|
handler: Custom handler (default: StreamHandler to stdout)
|
|
|
|
Returns:
|
|
Root logger for the package
|
|
"""
|
|
if format_string is None:
|
|
format_string = SIMPLE_FORMAT
|
|
|
|
# Get the package logger
|
|
logger = logging.getLogger(PACKAGE_NAME)
|
|
logger.setLevel(level)
|
|
|
|
# Remove existing handlers
|
|
logger.handlers.clear()
|
|
|
|
# Create handler if not provided
|
|
if handler is None:
|
|
handler = logging.StreamHandler(sys.stdout)
|
|
|
|
# Set format
|
|
formatter = logging.Formatter(format_string)
|
|
handler.setFormatter(formatter)
|
|
handler.setLevel(level)
|
|
|
|
# Add handler
|
|
logger.addHandler(handler)
|
|
|
|
return logger
|
|
|
|
|
|
def get_logger(name: str) -> logging.Logger:
|
|
"""
|
|
Get a logger for a specific module.
|
|
|
|
Args:
|
|
name: Module name (will be prefixed with package name)
|
|
|
|
Returns:
|
|
Logger instance
|
|
"""
|
|
return logging.getLogger(f"{PACKAGE_NAME}.{name}")
|
|
|
|
|
|
# Convenience functions for common log levels
|
|
def set_debug_logging() -> logging.Logger:
|
|
"""Enable debug-level logging."""
|
|
return setup_logging(level=logging.DEBUG)
|
|
|
|
|
|
def set_info_logging() -> logging.Logger:
|
|
"""Enable info-level logging."""
|
|
return setup_logging(level=logging.INFO)
|
|
|
|
|
|
def set_warning_logging() -> logging.Logger:
|
|
"""Enable warning-level logging (quieter)."""
|
|
return setup_logging(level=logging.WARNING)
|
|
|
|
|
|
def set_quiet_logging() -> logging.Logger:
|
|
"""Enable error-only logging (quietest)."""
|
|
return setup_logging(level=logging.ERROR)
|