Skip to content

Logging

any-agent comes with a logger powered by Rich.

By default, logging is set up for you. But if you want to customize it, you can call:

from any_agent.logging import setup_logger
setup_logger()
from any_agent.logging import setup_logger
import logging
setup_logger(level=logging.DEBUG)
setup_logger(log_format="%(asctime)s - %(levelname)s - %(message)s")
setup_logger(propagate=True)

Configure the any_agent logger with the specified settings.

def setup_logger(
level: int = 40,
rich_tracebacks: bool = True,
log_format: str | None = None,
propagate: bool = False,
**kwargs: Any,
) -> None
ParameterTypeDefaultDescription
levelint40The logging level to use (default: logging.INFO)
rich_tracebacksboolTrueWhether to enable rich tracebacks (default: True)
log_formatstr | NoneNoneOptional custom log format string
propagateboolFalseWhether to propagate logs to parent loggers (default: False)
**kwargsAnyrequiredAdditional keyword arguments to pass to RichHandler