rlog¶
import "github.com/jbcom/radioactive-ralph/internal/rlog"
Package rlog is a thin slog wrapper that emits records shaped like Claude’s stream-json events when the caller opts into JSON output. Default (text) output is operator-facing human logging on stderr.
The shape is intentionally aligned with claude’s stream-json so operator-facing and subprocess-facing log streams can be multiplexed through the same tooling:
{"type":"ralph","event":"init.start","ts":"2026-04-15T...","repo":"..."}
`type: ralph` disambiguates ralph-emitted records from claude-emitted `type: assistant` / `type: user` records when an operator tails a merged log stream.
Index¶
func FromContext¶
func FromContext(ctx context.Context) *slog.Logger
FromContext retrieves the logger attached by WithLogger, or returns the default slog logger if none. Callers can use this without threading a *slog.Logger through every function signature.
func New¶
func New(mode Mode, w io.Writer) *slog.Logger
New returns a *slog.Logger configured for the requested mode. Writer defaults to os.Stderr when nil.
func WithLogger¶
func WithLogger(ctx context.Context, logger *slog.Logger) context.Context
WithLogger attaches a logger to ctx for downstream callers.
type Mode¶
Mode controls the output format selected by the CLI.
type Mode string
const (
// ModeText is the default human-readable stderr output.
ModeText Mode = "text"
// ModeJSON emits one JSON record per log call, shaped like
// claude stream-json events with type=ralph.
ModeJSON Mode = "json"
)
Generated by gomarkdoc