errcapture

package
v0.19.1306 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2026 License: AGPL-3.0 Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package errcapture captures a runner job execution's error-level log output so it can be attached to the failed execution result as rich diagnostics.

Why this exists: tools like terraform emit their real error detail (e.g. an AWS "AccessDenied ... is not authorized to perform: s3:CreateBucket") into the log stream via structured @level:"error" records, while the Go error the runner wraps up is often just "exit status 1". ctl-api parses the failed result's error text into a structured composite error, so it needs the rich text, not the thin wrapper.

A Capture is a zapcore.Core teed into the per-execution job logger. It records error-level entries into a bounded in-memory buffer. The runner's API client decorator reads the buffer and attaches it to the result under MetadataKey when a job reports failure — one universal chokepoint, no per-handler wiring.

Index

Constants

View Source
const MetadataKey = "error_output"

MetadataKey is the error-metadata key the captured output is attached under. It must match the key ctl-api prefers when parsing a failed result (services/ctl-api/.../create_runner_job_execution_result.go: errMetaKeyOutput).

Variables

This section is empty.

Functions

func NewContext

func NewContext(ctx context.Context, cap *Capture) context.Context

NewContext returns ctx carrying cap so downstream code (the API client decorator) can read the captured output.

func Output

func Output(ctx context.Context) string

Output is a nil-safe shortcut for FromContext(ctx).String().

Types

type Capture

type Capture struct {
	// contains filtered or unexported fields
}

Capture accumulates error-level log lines for one job execution. It is safe for concurrent use: the job logger it feeds is shared across the execution's goroutines (steps, monitor).

func FromContext

func FromContext(ctx context.Context) *Capture

FromContext returns the Capture on ctx, or nil when none is set.

func New

func New() *Capture

New returns an empty Capture with the default size bound.

func (*Capture) Core

func (c *Capture) Core() zapcore.Core

Core returns the zapcore.Core to tee into the job logger. It only accepts error-level and above entries.

func (*Capture) String

func (c *Capture) String() string

String returns the captured lines joined by newlines. Safe to call on a nil Capture (returns "").

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL