gmuse.logging#

Structured logging for gmuse with debug mode support.

This module provides a centralized logging configuration that can be toggled via the GMUSE_DEBUG environment variable.

Public API: - setup_logger: Configure and return a logger with appropriate settings - get_logger: Get an existing logger or create a new one - configure_litellm_logging: Configure litellm library logging

Environment Variables: - GMUSE_DEBUG: Set to “1”, “true”, or “yes” to enable debug logging

Module Contents#

Functions#

setup_logger

Configure and return a logger with appropriate settings.

get_logger

Get an existing logger or create a new one with default settings.

configure_litellm_logging

Configure litellm library logging based on debug mode.

Data#

_DEBUG_ENV_VALUES

Environment variable values that enable debug mode.

_LOG_FORMAT

Log message format (simple, no timestamps for CLI tool).

API#

gmuse.logging._DEBUG_ENV_VALUES: Final[frozenset[str]] = 'frozenset(...)'#

Environment variable values that enable debug mode.

gmuse.logging._LOG_FORMAT: Final[str] = '[%(levelname)s] %(message)s'#

Log message format (simple, no timestamps for CLI tool).

gmuse.logging.setup_logger(name: str = 'gmuse', level: Optional[int] = None, log_file: Optional[str] = None) logging.Logger#

Configure and return a logger with appropriate settings.

Args: name: Logger name, defaults to “gmuse” level: Logging level, defaults to INFO or DEBUG based on GMUSE_DEBUG env var log_file: Optional file path for log output. If provided, logs go to file instead of stderr.

Returns: Configured logger instance

Example: >>> logger = setup_logger() >>> logger.debug(“This only shows when GMUSE_DEBUG=1”) >>> logger.info(“This always shows”) >>> # With file logging: >>> logger = setup_logger(log_file=”~/.cache/gmuse/debug.log”)

gmuse.logging.get_logger(name: str = 'gmuse') logging.Logger#

Get an existing logger or create a new one with default settings.

Args: name: Logger name, defaults to “gmuse”

Returns: Logger instance

Example: >>> from gmuse.logging import get_logger >>> logger = get_logger() >>> logger.info(“Loading configuration…”)

gmuse.logging.configure_litellm_logging() None#

Configure litellm library logging based on debug mode.

Suppresses litellm’s verbose debug output unless GMUSE_DEBUG is enabled. This should be called once when the llm_client module is imported.