- Create shared/filename_utils.py for date/time/dimension filename building - Create shared/path_utils.py for output directory handling - Create shared/discord/message_builder.py for Discord message construction - Create shared/discord/cdn_extractor.py for CDN URL extraction - Refactor image_node.py to use shared utilities (-161 lines, 16.3%) - Refactor video_node.py to use shared utilities (-361 lines, 23.1%) - Fix setup_logging missing from logging_config.py - Fix test imports to use new module paths (nodes.* instead of discord_*_node) - Total reduction: 522 lines (20.5%), exceeding PRD target of ~200 lines Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
60 lines
1.3 KiB
Python
60 lines
1.3 KiB
Python
"""
|
|
Logging configuration for ComfyUI-DiscordSend
|
|
|
|
Provides a configured logger for the extension.
|
|
"""
|
|
|
|
import logging
|
|
import sys
|
|
|
|
|
|
def setup_logging(level: int = logging.INFO) -> None:
|
|
"""
|
|
Set up logging configuration for the application.
|
|
|
|
Args:
|
|
level: The logging level to use (default: INFO)
|
|
"""
|
|
logging.basicConfig(
|
|
level=level,
|
|
format='[%(name)s] %(levelname)s: %(message)s',
|
|
handlers=[
|
|
logging.StreamHandler(sys.stdout)
|
|
]
|
|
)
|
|
|
|
|
|
def get_logger(name: str = "comfyui_discordsend") -> logging.Logger:
|
|
"""
|
|
Get a configured logger for the extension.
|
|
|
|
Args:
|
|
name: The logger name (default: comfyui_discordsend)
|
|
|
|
Returns:
|
|
Configured logger instance
|
|
"""
|
|
logger = logging.getLogger(name)
|
|
|
|
# Only configure if not already configured
|
|
if not logger.handlers:
|
|
logger.setLevel(logging.DEBUG)
|
|
|
|
# Console handler
|
|
console_handler = logging.StreamHandler(sys.stdout)
|
|
console_handler.setLevel(logging.INFO)
|
|
|
|
# Format
|
|
formatter = logging.Formatter(
|
|
'[%(name)s] %(levelname)s: %(message)s'
|
|
)
|
|
console_handler.setFormatter(formatter)
|
|
|
|
logger.addHandler(console_handler)
|
|
|
|
return logger
|
|
|
|
|
|
# Default logger instance
|
|
logger = get_logger()
|