Saltar al contenido principal

Horus Runtime Logging

horus-runtime uses Loguru for logging. A global logger is configured automatically and can be used throughout the project.

Usage

Import the shared logger:

from horus_runtime.logger import horus_logger

horus_logger.info("Starting runtime")
horus_logger.debug("Executor initialized")
horus_logger.error("Task failed")

Configuration

Logging behavior is configured via environment variables using the prefix:

HORUS_LOGGER_

Example configuration:

HORUS_LOGGER_LEVEL=DEBUG
HORUS_LOGGER_LOG_DIRECTORY=logs
HORUS_LOGGER_ROTATION="10 MB"
HORUS_LOGGER_RETENTION="7 days"

Available Settings

SettingDefaultDescription
LEVELINFOMinimum log level
LOG_DIRECTORYlogsDirectory where logs are written
ROTATION10 MBMax file size before rotating logs
RETENTION7 daysHow long to keep log files
COMPRESSIONNoneCompression format for old logs
FILENAME_TEMPLATElog_{time:YYYY-MM-DD}.logTemplate for log file names

Features

  • Logs to both console and file
  • Automatic log rotation
  • Configurable retention and compression
  • Environment-based configuration via Pydantic Settings
  • Structured logs with timestamps, level, function, and line number

Log Files

By default, logs are written to:

logs/log_YYYY-MM-DD.log

The directory is created automatically if it does not exist.

Why Not print()?

print() should never be used in horus-runtime. Always use the configured logger so logs remain structured, persistent, and configurable.

Example of proper logging:

horus_logger.info("Task completed successfully")
horus_logger.warning("Missing optional field, using default")
horus_logger.exception("Task failed due to exception")