Documentation
¶
Overview ¶
Package logcapture streams every container's stdout/stderr in a block into one combined, interleaved log file for the block's whole lifetime, so a scenario failure has the product's own logs available, not only the client-side symptom.
Index ¶
Constants ¶
const EnvOut = "IT_LOG_OUT"
EnvOut overrides the default log capture output directory.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Sink ¶
type Sink struct {
// contains filtered or unexported fields
}
Sink resolves where each block's combined container log file is written.
func NewSink ¶
NewSink creates a unique directory for a new log capture run beneath root, isolated beneath its own ".run-*" directory so a stale local run's log files are never mixed with a fresh run's.
func (*Sink) FileFor ¶
FileFor returns the combined-log file path for the named block, creating its containing directory. Safe to call concurrently for different blocks.
func (*Sink) SharedFileFor ¶
SharedFileFor returns the log file path for a component shared across blocks, creating its containing directory. Shared components are started once and outlive every block, so their output belongs to the run rather than to whichever block happened to start them. Safe to call concurrently for different components.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer streams many containers' log lines into one combined file, prefixed per component the way `docker compose up` interleaves its services' output. Every Consumer's Accept is a non-blocking send: a full buffer drops the line and counts it, rather than ever blocking the caller.
lines is never closed: a container's own log-producer goroutine (owned by testcontainers, not this package) keeps calling Accept for as long as the container exists, independent of when the block decides to Close its Writer — closing the channel itself would race that producer and panic on a send to a closed channel. Close instead signals stop and lets run drain whatever already arrived.
func NewWriter ¶
NewWriter creates path and starts the background goroutine that drains lines into it. Call Close when the block tears down to flush and release the file.
func (*Writer) Close ¶
func (w *Writer) Close()
Close signals the writer goroutine to drain and flush what has already arrived, then waits for it to finish and closes the file. Safe to call once per Writer, and safe to call while a container's log producer is still delivering lines — Accept remains a harmless no-op send into an unread channel afterward, never a panic or a block.
func (*Writer) Consumer ¶
func (w *Writer) Consumer(component string) testcontainers.LogConsumer
Consumer returns a testcontainers.LogConsumer that forwards a single component's log lines into this writer, tagged with component in the combined file.