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

__init__()[source][source]
get_logger(name: str | None = None) Logger[source][source]

Get a logger instance

set_level(level: str) None[source][source]

Set logging level

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:

logging.Logger

tooluniverse.logging_config.set_log_level(level: str) None[source][source]

Set global log level

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

Log debug message

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

Log info message

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

Log progress message

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

Log warning message

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

Log error message

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

Log critical message

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

Log info message

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

Log debug message

tooluniverse.logging_config.progress(msg, *args, **kwargs) None[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:

logging.Logger

tooluniverse.logging_config.log_hook_execution(hook_name: str, tool_name: str, execution_time: float, success: bool)[source][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