TestcontainerEx.LogConsumer (testcontainer_ex v0.9.0)

Copy Markdown View Source

Streams container stdout/stderr to Elixir's Logger.

Attach via TestcontainerEx.Container.with_log_consumer/2 on the container config, then call start_link/3 after the container is running.

Example

config =
  TestcontainerEx.Container.new("postgres:15-alpine")
  |> TestcontainerEx.Container.with_log_consumer(:debug)

{:ok, container} = TestcontainerEx.start_container(config)

Summary

Functions

Starts a linked task that streams container logs to Logger.

Functions

start_link(container_id, conn, level \\ :debug)

@spec start_link(String.t(), Req.Request.t(), Logger.level()) :: {:ok, pid()}

Starts a linked task that streams container logs to Logger.

Parameters

  • container_id — the Docker container ID
  • conn — the Req connection to the Docker API
  • level — Logger level (:debug, :info, :warning, :error), default :debug