TestcontainerEx.Log (testcontainer_ex v0.3.0)

Copy Markdown View Source

Structured logging convenience for TestcontainerEx.

Wraps Elixir's Logger with contextual metadata (container ID, image, session, engine) so log lines are easy to filter and correlate.

Usage

# Inside container lifecycle code:
import TestcontainerEx.Log

log_info("Container started", container_id: id, image: img)
log_debug("Pulling image", image: img)
log_warning("Ryuk disabled", reason: :config)

Configuration

All functions respect the standard :logger configuration. The metadata keys :testcontainer_ex, :container_id, and :image are automatically included when provided.

Summary

Functions

Logs a debug message with optional TestcontainerEx metadata.

Logs an error message with optional TestcontainerEx metadata.

Logs an informational message with optional TestcontainerEx metadata.

Logs a message at the given level with optional TestcontainerEx metadata.

Logs a warning message with optional TestcontainerEx metadata.

Functions

debug(message, meta \\ [])

@spec debug(
  String.t(),
  keyword()
) :: :ok

Logs a debug message with optional TestcontainerEx metadata.

Examples

log_debug("Pulling image", image: "redis:7")

error(message, meta \\ [])

@spec error(
  String.t(),
  keyword()
) :: :ok

Logs an error message with optional TestcontainerEx metadata.

Examples

log_error("Failed to start container", container_id: id, error: reason)

info(message, meta \\ [])

@spec info(
  String.t(),
  keyword()
) :: :ok

Logs an informational message with optional TestcontainerEx metadata.

Examples

log_info("Container started", container_id: "abc123", image: "postgres:15")

log(level, message, meta \\ [])

@spec log(Logger.level(), String.t(), keyword()) :: :ok

Logs a message at the given level with optional TestcontainerEx metadata.

warning(message, meta \\ [])

@spec warning(
  String.t(),
  keyword()
) :: :ok

Logs a warning message with optional TestcontainerEx metadata.

Examples

log_warning("Ryuk disabled — containers will not auto-clean", reason: :config)