logger

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: Apache-2.0 Imports: 2 Imported by: ? modules, 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 logger provides interfaces and implementations for routing stdout/stderr output from runtime CLI commands to the user.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithLogger

func WithLogger(ctx context.Context, l Logger) context.Context

WithLogger returns a new context with the logger attached.

Types

type Logger

type Logger interface {
	// Stdout returns the writer for standard output from runtime commands.
	Stdout() io.Writer

	// Stderr returns the writer for standard error from runtime commands.
	Stderr() io.Writer
}

Logger provides writers for routing stdout and stderr of runtime CLI commands.

func FromContext

func FromContext(ctx context.Context) Logger

FromContext retrieves the logger from context. Returns a NoOpLogger if no logger is in context.

func NewNoOpLogger

func NewNoOpLogger() Logger

NewNoOpLogger creates a new no-op logger.

func NewTextLogger

func NewTextLogger(stdout, stderr io.Writer) Logger

NewTextLogger creates a new logger that writes to the given stdout and stderr writers. If either writer is nil, it defaults to io.Discard.

Jump to

Keyboard shortcuts

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