Temple Compute Docs

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.

Task log files

Each task also writes its own log to <LOG_DIRECTORY>/<task id>.log (a / in the id becomes _), attached to the task as the side artifact <task id>_logs. It holds the task's log records and its stdout and stderr.

Every run of the task starts with a header line:

--- attempt 1 ---

The first attempt in a workflow run starts a fresh file. A retry appends --- attempt 2 --- and so on, so the file keeps every attempt.

A command's stderr is logged at INFO, like its stdout: tools write progress there, and a failure is the exit code, not the stream. When a shell command exits non-zero, its ERROR line ends with the last 20 lines it wrote to stderr, which CommandFailedError.output also holds.

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")

On this page