tooluniverse.logging_config module¶
Global logging configuration for ToolUniverse
This module provides a centralized logging system based on Python’s standard logging module. It allows controlling debug output across the entire ToolUniverse project with different verbosity levels.
- Usage:
# Set log level via environment variable export TOOLUNIVERSE_LOG_LEVEL=DEBUG
# Or set programmatically from tooluniverse.logging_config import setup_logging, get_logger setup_logging(‘DEBUG’)
# Use in your code logger = get_logger(__name__) logger.info(“This is an info message”) logger.debug(“This is a debug message”)
- class tooluniverse.logging_config.ToolUniverseFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)[source][source]¶
Bases:
Formatter
Custom formatter with colored output and emoji prefixes
- COLORS = {'CRITICAL': '\x1b[35m', 'DEBUG': '\x1b[36m', 'ERROR': '\x1b[31m', 'INFO': '\x1b[32m', 'PROGRESS': '\x1b[34m', 'RESET': '\x1b[0m', 'WARNING': '\x1b[33m'}[source]¶
- EMOJI_PREFIX = {'CRITICAL': '🚨 ', 'DEBUG': '🔧 ', 'ERROR': '❌ ', 'INFO': 'ℹ️ ', 'PROGRESS': '⏳ ', 'WARNING': '⚠️ '}[source]¶
- format(record)[source][source]¶
Format the specified record as text.
The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.
- class tooluniverse.logging_config.ToolUniverseLogger[source][source]¶
Bases:
object
Singleton logger manager for ToolUniverse
- tooluniverse.logging_config.setup_logging(level: str | None = None) None [source][source]¶
Setup global logging configuration
- Parameters:
level (str) – Log level (‘DEBUG’, ‘INFO’, ‘WARNING’, ‘ERROR’, ‘CRITICAL’)
- tooluniverse.logging_config.get_logger(name: str | None = None) Logger [source][source]¶
Get a logger instance
- Parameters:
name (str, optional) – Logger name (usually __name__)
- Returns:
Logger instance
- Return type:
- tooluniverse.logging_config.progress_log(msg, *args, **kwargs) None [source][source]¶
Log progress message
- tooluniverse.logging_config.get_hook_logger(name: str = 'HookManager') Logger [source][source]¶
Get a logger specifically configured for hook operations.
- Parameters:
name (str) – Name of the logger. Defaults to ‘HookManager’
- Returns:
Configured logger for hook operations
- Return type: