calute.logging.console#
Lightweight logging system for Calute using ANSI colors.
This module provides a centralized, color-coded logging system for the Calute framework. It includes: - ANSI color support for terminal output - Thread-safe singleton logger implementation - Colored log level formatting - Utility functions for common logging patterns - Streaming callback for real-time event display
The logging system automatically detects TTY terminals and applies ANSI colors accordingly, falling back to plain text in non-TTY contexts.
Example
>>> from calute.logging.console import get_logger, log_step
>>> logger = get_logger()
>>> logger.info("Starting process")
>>> log_step("INIT", "Initializing components", color="GREEN")
- class calute.logging.console.CaluteLogger[source]#
Bases:
objectCentralized logger for Calute with colored output support.
Thread-safe singleton logger that provides colored console output with configurable log levels. Uses the singleton pattern to ensure a single logger instance across the application.
- logger#
The underlying Python logging.Logger instance.
Note
Log level can be configured via the CALUTE_LOG_LEVEL environment variable. Defaults to INFO if not set.
- critical(message: str, *args, **kwargs)[source]#
Log a message at CRITICAL level.
- Parameters
message – The message to log.
*args – Positional arguments for string formatting.
**kwargs – Keyword arguments passed to the logger.
- debug(message: str, *args, **kwargs)[source]#
Log a message at DEBUG level.
- Parameters
message – The message to log.
*args – Positional arguments for string formatting.
**kwargs – Keyword arguments passed to the logger.
- error(message: str, *args, **kwargs)[source]#
Log a message at ERROR level.
- Parameters
message – The message to log.
*args – Positional arguments for string formatting.
**kwargs – Keyword arguments passed to the logger.
- info(message: str, *args, **kwargs)[source]#
Log a message at INFO level.
- Parameters
message – The message to log.
*args – Positional arguments for string formatting.
**kwargs – Keyword arguments passed to the logger.
- class calute.logging.console.ColorFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)[source]#
Bases:
FormatterCustom log formatter that adds ANSI color codes to log output.
This formatter colorizes log messages based on their severity level and adds timestamps and logger names with appropriate styling.
The formatter handles multi-line messages by prepending the formatted name to each line, ensuring consistent visual alignment.
- calute.logging.console.get_logger() CaluteLogger[source]#
Get the singleton CaluteLogger instance.
- Returns
The global CaluteLogger singleton instance.
Example
>>> logger = get_logger() >>> logger.info("Application started")
- calute.logging.console.log_agent_start(agent: str | None = None)[source]#
Log the initialization of an agent.
- Parameters
agent – Name of the agent being started.
- calute.logging.console.log_delegation(from_agent: str, to_agent: str)[source]#
Log an agent delegation event with arrow visualization.
Displays a formatted message showing control transfer from one agent to another.
- Parameters
from_agent – Name of the delegating agent.
to_agent – Name of the agent receiving delegation.
- calute.logging.console.log_error(message: str)[source]#
Log an error message with cross emoji and red color.
- Parameters
message – The error message to display.
- calute.logging.console.log_retry(attempt: int, max_attempts: int, error: str)[source]#
Log a retry attempt with attempt counter and error details.
- Parameters
attempt – Current attempt number (1-based).
max_attempts – Maximum number of attempts allowed.
error – Description of the error that triggered the retry.
- calute.logging.console.log_step(step_name: str, description: str = '', color: str = 'CYAN')[source]#
Log a step in the process with formatted, colored output.
Displays a step name in brackets with optional description. Colors are applied only when output is to a TTY terminal.
- Parameters
step_name – Name of the step (displayed in brackets).
description – Optional description following the step name.
color – Color name from COLORS dict (default: “CYAN”).
Example
>>> log_step("INIT", "Loading configuration") >>> log_step("BUILD", "Compiling assets", color="GREEN")
- calute.logging.console.log_success(message: str)[source]#
Log a success message with rocket emoji and blue color.
- Parameters
message – The success message to display.
- calute.logging.console.log_task_complete(task_name: str, duration: float | None = None)[source]#
Log task completion with optional duration.
- Parameters
task_name – Name of the completed task.
duration – Optional execution duration in seconds.
- calute.logging.console.log_task_start(task_name: str, agent: str | None = None)[source]#
Log the start of a task with optional agent context.
- Parameters
task_name – Name or description of the task being started.
agent – Optional name of the agent executing the task.
- calute.logging.console.log_thinking(agent_name: str)[source]#
Log an agent’s thinking state with colored brain emoji.
Displays a visual indicator that an agent is processing or thinking, with blue/purple coloring in TTY terminals.
- Parameters
agent_name – Name of the agent that is currently thinking.
- calute.logging.console.log_warning(message: str)[source]#
Log a warning message with warning emoji and yellow color.
- Parameters
message – The warning message to display.
- calute.logging.console.set_verbosity(level: str)[source]#
Set the global verbosity level for the Calute logger.
- Parameters
level – Log level name (‘DEBUG’, ‘INFO’, ‘WARNING’, ‘ERROR’, ‘CRITICAL’).
Example
>>> set_verbosity('DEBUG') # Enable verbose output >>> set_verbosity('ERROR') # Only show errors
- calute.logging.console.stream_callback(chunk)[source]#
Purple-accented streaming callback for real-time event display.
Handles various event types from the Calute streaming system and displays them with appropriate formatting, colors, and timing information. Maintains internal state for tracking tool calls and execution times.
Supports the following event types: - StreamChunk: Content streaming and tool call arguments - FunctionDetection: Detection of function calls in output - FunctionCallsExtracted: List of extracted function calls - FunctionExecutionStart: Beginning of function execution - FunctionExecutionComplete: Completion of function execution - AgentSwitch: Agent transition events - ReinvokeSignal: Re-invocation signals - Completion: Task/pipeline completion events
- Parameters
chunk – Event object from the streaming system. Can be any of the supported event types defined in calute.types.
Note
Uses internal state to track tool call headers, indentation, and execution timing across multiple calls.