logging

package
v2.935.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LevelFromEnv

func LevelFromEnv() zapcore.Level

func LogWarning

func LogWarning(ctx context.Context, msg string, err error)

func With

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

With returns a new context with the given logger added to the context.

func WithFields

func WithFields(ctx context.Context, fields ...zap.Field) context.Context

WithFields returns a new context with the given fields added to the logger.

func WithStepCtx

func WithStepCtx(ctx context.Context, name string, fn func(ctx context.Context) error) error

func WithWarningLogger

func WithWarningLogger(ctx context.Context, l *WarningLogger) context.Context

Types

type Logger

type Logger interface {
	Debug(msg string, fields ...zapcore.Field)
	Info(msg string, fields ...zapcore.Field)
	Warn(msg string, fields ...zapcore.Field)
	Error(msg string, fields ...zapcore.Field)
	Github(msg string) // Prints only when running in GitHub Actions
	With(fields ...zapcore.Field) Logger

	// Scope returns a Logger with a path prefix for StartStep calls.
	// Scopes can be nested: logger.Scope("A").Scope("B").StartStep("C")
	// produces path ["A", "B", "C"] in the workflow tracking UI.
	Scope(name string) Logger

	// StartStep starts a trackable progress step.
	// The step appears as "pending" until Succeed/Fail/Skip is called.
	// Path is formed by: [scope prefix...] + msg
	StartStep(msg string) Step
}

func From

func From(ctx context.Context) Logger

From returns the logger associated with the given context.

type OnWarningLogged

type OnWarningLogged func(err error)

type Step

type Step interface {
	Succeed()
	Fail()
	Skip()
}

Step is a handle for tracking progress of an operation. Call Succeed(), Fail(), or Skip() when the operation completes.

func StartStepCtx

func StartStepCtx(ctx context.Context, name string) Step

type StepStatus

type StepStatus string

StepStatus represents the outcome of a progress step.

const (
	StepStatusPending StepStatus = "pending"
	StepStatusSuccess StepStatus = "success"
	StepStatusFailed  StepStatus = "failed"
	StepStatusSkipped StepStatus = "skipped"
)

type WarningLogger

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

func NewWarningLogger

func NewWarningLogger(validationOnly bool, onWarningLogged OnWarningLogged) *WarningLogger

func WarningLoggerFrom

func WarningLoggerFrom(ctx context.Context) (*WarningLogger, bool)

func (*WarningLogger) DisableLogging

func (w *WarningLogger) DisableLogging()

func (*WarningLogger) GetWarnings

func (w *WarningLogger) GetWarnings() []error

func (*WarningLogger) LogWarning

func (w *WarningLogger) LogWarning(ctx context.Context, msg string, err error)

type ZapLogger

type ZapLogger struct {
	*zap.Logger
	// contains filtered or unexported fields
}

ZapLogger wraps zap.Logger and implements the Logger interface.

func NewFileLogger

func NewFileLogger(lvl zapcore.Level, outFile string) *ZapLogger

func NewLogger

func NewLogger(lvl zapcore.Level) *ZapLogger

func NewLoggerFromZap

func NewLoggerFromZap(l *zap.Logger) *ZapLogger

func (*ZapLogger) Github

func (l *ZapLogger) Github(msg string)

func (*ZapLogger) Scope

func (l *ZapLogger) Scope(name string) Logger

func (*ZapLogger) StartStep

func (l *ZapLogger) StartStep(msg string) Step

func (*ZapLogger) With

func (l *ZapLogger) With(fields ...zapcore.Field) Logger

Jump to

Keyboard shortcuts

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