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[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'}¶
- EMOJI_PREFIX = {'CRITICAL': '🚨 ', 'DEBUG': '🔧 ', 'ERROR': '❌ ', 'INFO': 'ℹ️ ', 'PROGRESS': '⏳ ', 'WARNING': '⚠️ '}¶
- format(record)[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]¶
Bases:
object
Singleton logger manager for ToolUniverse
- tooluniverse.logging_config.reconfigure_for_stdio()[source]¶
Reconfigure logging to output to stderr for stdio mode.
This function should be called at the very beginning of stdio mode to ensure all logs go to stderr instead of stdout.
- tooluniverse.logging_config.setup_logging(level=None)[source]¶
Setup global logging configuration
- Parameters:
level (
str
) – Log level (‘DEBUG’, ‘INFO’, ‘WARNING’, ‘ERROR’, ‘CRITICAL’)
- tooluniverse.logging_config.get_logger(name=None)[source]¶
Get a logger instance
- Parameters:
name (
str, optional
) – Logger name (usually __name__)- Returns:
Logger instance
- Return type:
- tooluniverse.logging_config.minimal(msg, *args, **kwargs)¶
Log info message
- tooluniverse.logging_config.verbose(msg, *args, **kwargs)¶
Log debug message
- tooluniverse.logging_config.progress(msg, *args, **kwargs)¶
Log progress message
- tooluniverse.logging_config.get_hook_logger(name='HookManager')[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: