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

static __new__(cls)[source]
__init__()[source]
reconfigure_for_stdio()[source]

Reconfigure logger to output to stderr for stdio mode

get_logger(name=None)[source]

Get a logger instance

set_level(level)[source]

Set logging level

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:

logging.Logger

tooluniverse.logging_config.set_log_level(level)[source]

Set global log level

tooluniverse.logging_config.debug(msg, *args, **kwargs)[source]

Log debug message

tooluniverse.logging_config.info(msg, *args, **kwargs)[source]

Log info message

tooluniverse.logging_config.progress_log(msg, *args, **kwargs)[source]

Log progress message

tooluniverse.logging_config.warning(msg, *args, **kwargs)[source]

Log warning message

tooluniverse.logging_config.error(msg, *args, **kwargs)[source]

Log error message

tooluniverse.logging_config.critical(msg, *args, **kwargs)[source]

Log critical message

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:

logging.Logger

tooluniverse.logging_config.log_hook_execution(hook_name, tool_name, execution_time, success)[source]

Log hook execution details for monitoring and debugging.

Parameters:
  • hook_name (str) – Name of the hook that was executed

  • tool_name (str) – Name of the tool the hook was applied to

  • execution_time (float) – Time taken to execute the hook in seconds

  • success (bool) – Whether the hook execution was successful