logging

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package logging provides structured logging utilities for BubuStack controllers.

This package contains a ControllerLogger that provides consistent structured logging across all controllers, with context-aware logging for StoryRuns, StepRuns, and other BubuStack resources.

Controller Logger

The ControllerLogger wraps logr.Logger with resource-aware methods:

log := logging.NewControllerLogger(ctx, "StoryRunController")
log = log.WithStoryRun(storyRun)
log.Info("Processing story run")
log.Error(err, "Failed to reconcile")

Resource Context

Add resource context to loggers:

log.WithStoryRun(storyRun)    // Adds storyrun, namespace, story, phase
log.WithStepRun(stepRun)      // Adds steprun, namespace, storyrun
log.WithEngram(engram)        // Adds engram, namespace, template
log.WithImpulse(impulse)      // Adds impulse, namespace, story
log.WithTransport(transport)  // Adds transport, namespace

Logging Methods

Standard logging methods:

log.Info("message", "key", "value")
log.Error(err, "message", "key", "value")
log.Debug("debug message")  // Only emitted at V(1) or higher
log.V(level).Info("verbose message")

Feature Flags

Feature flags control logging behavior through [features.go]:

logging.SetFeatureEnabled("detailed-metrics", true)
if logging.IsFeatureEnabled("detailed-metrics") { ... }

This package integrates with controller-runtime's logging infrastructure and the standard logr interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnableStepOutputLogging added in v0.1.4

func EnableStepOutputLogging(enabled bool)

EnableStepOutputLogging toggles whether step outputs should be logged when aggregated.

func EnableVerboseLogging added in v0.1.4

func EnableVerboseLogging(enabled bool)

EnableVerboseLogging toggles whether verbosity>0 logs should be emitted.

func StepOutputLoggingEnabled added in v0.1.4

func StepOutputLoggingEnabled() bool

StepOutputLoggingEnabled reports whether step outputs should be logged during DAG reconciliation.

func VerboseLoggingEnabled added in v0.1.4

func VerboseLoggingEnabled() bool

VerboseLoggingEnabled reports whether verbosity-gated logs should be emitted.

Types

type CELLogger

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

CELLogger implements the observability.Logger interface for CEL evaluation logging.

func NewCELLogger

func NewCELLogger(baseLogger logr.Logger) *CELLogger

NewCELLogger creates a new CELLogger from a base logger.

func (*CELLogger) CacheHit

func (l *CELLogger) CacheHit(expression, expressionType string)

CacheHit logs a cache hit event.

func (*CELLogger) EvaluationError

func (l *CELLogger) EvaluationError(err error, expression, expressionType string, duration time.Duration)

EvaluationError logs a CEL evaluation error

func (*CELLogger) EvaluationStart

func (l *CELLogger) EvaluationStart(expression, expressionType string)

EvaluationStart logs the start of a CEL evaluation

func (*CELLogger) EvaluationSuccess

func (l *CELLogger) EvaluationSuccess(expression, expressionType string, duration time.Duration, result any)

EvaluationSuccess logs a successful CEL evaluation

type CleanupLogger

type CleanupLogger struct {
	*ControllerLogger
}

CleanupLogger provides specialized logging for cleanup operations

func NewCleanupLogger

func NewCleanupLogger(ctx context.Context, resourceType string) *CleanupLogger

NewCleanupLogger creates a logger for cleanup operations

func (*CleanupLogger) CleanupError

func (cl *CleanupLogger) CleanupError(err error, resourceName string, keysAndValues ...any)

CleanupError logs cleanup error

func (*CleanupLogger) CleanupStart

func (cl *CleanupLogger) CleanupStart(resourceName string, keysAndValues ...any)

CleanupStart logs cleanup start

func (*CleanupLogger) CleanupSuccess

func (cl *CleanupLogger) CleanupSuccess(resourceName string, duration time.Duration, keysAndValues ...any)

CleanupSuccess logs cleanup success

type ControllerLogger

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

ControllerLogger provides structured logging for controllers

func NewControllerLogger

func NewControllerLogger(ctx context.Context, controller string) *ControllerLogger

NewControllerLogger creates a new structured logger

func (*ControllerLogger) Error

func (cl *ControllerLogger) Error(err error, msg string, keysAndValues ...any)

Error logs an error message

func (*ControllerLogger) Info

func (cl *ControllerLogger) Info(msg string, keysAndValues ...any)

Info logs an info message

func (*ControllerLogger) Logr added in v0.1.4

func (cl *ControllerLogger) Logr() logr.Logger

Logr exposes the underlying logr.Logger so shared helpers can log consistently.

func (*ControllerLogger) V

func (cl *ControllerLogger) V(level int) logr.Logger

V returns a logger for a specific verbosity level

func (*ControllerLogger) WithDuration

func (cl *ControllerLogger) WithDuration(duration time.Duration) *ControllerLogger

WithDuration adds duration to the logger context

func (*ControllerLogger) WithEngram

func (cl *ControllerLogger) WithEngram(engram *bubushv1alpha1.Engram) *ControllerLogger

WithEngram returns a logger with Engram context

func (*ControllerLogger) WithError

func (cl *ControllerLogger) WithError(err error) *ControllerLogger

WithError adds error to the logger context

func (*ControllerLogger) WithImpulse

func (cl *ControllerLogger) WithImpulse(impulse *bubushv1alpha1.Impulse) *ControllerLogger

WithImpulse returns a logger with Impulse context

func (*ControllerLogger) WithStepRun

func (cl *ControllerLogger) WithStepRun(steprun *runsv1alpha1.StepRun) *ControllerLogger

WithStepRun returns a logger with StepRun context

func (*ControllerLogger) WithStory

func (cl *ControllerLogger) WithStory(story *bubushv1alpha1.Story) *ControllerLogger

WithStory returns a logger with Story context

func (*ControllerLogger) WithStoryRun

func (cl *ControllerLogger) WithStoryRun(srun *runsv1alpha1.StoryRun) *ControllerLogger

WithStoryRun returns a logger with StoryRun context

func (*ControllerLogger) WithTransport added in v0.1.4

func (cl *ControllerLogger) WithTransport(transport *transportv1alpha1.Transport) *ControllerLogger

WithTransport returns a logger with Transport context

func (*ControllerLogger) WithValues

func (cl *ControllerLogger) WithValues(keysAndValues ...any) *ControllerLogger

WithValues adds custom key-value pairs to the logger

type LoggerKey

type LoggerKey struct{}

LoggerKey is used for storing logger in context

type ReconcileLogger

type ReconcileLogger struct {
	*ControllerLogger
	// contains filtered or unexported fields
}

ReconcileLogger provides specialized logging for reconcile operations

func NewReconcileLogger

func NewReconcileLogger(ctx context.Context, controller string) *ReconcileLogger

NewReconcileLogger creates a logger for reconcile operations

func (*ReconcileLogger) ReconcileError

func (rl *ReconcileLogger) ReconcileError(err error, msg string, keysAndValues ...any)

ReconcileError logs reconciliation error

func (*ReconcileLogger) ReconcileRequeue

func (rl *ReconcileLogger) ReconcileRequeue(msg string, after time.Duration, keysAndValues ...any)

ReconcileRequeue logs reconciliation requeue

func (*ReconcileLogger) ReconcileStart

func (rl *ReconcileLogger) ReconcileStart(msg string, keysAndValues ...any)

ReconcileStart logs the start of reconciliation

func (*ReconcileLogger) ReconcileSuccess

func (rl *ReconcileLogger) ReconcileSuccess(msg string, keysAndValues ...any)

ReconcileSuccess logs successful reconciliation

type StepLogger

type StepLogger struct {
	*ControllerLogger
}

StepLogger provides specialized logging for step operations

func NewStepLogger

func NewStepLogger(ctx context.Context, steprun *runsv1alpha1.StepRun) *StepLogger

NewStepLogger creates a logger for step operations

func (*StepLogger) StepError

func (sl *StepLogger) StepError(err error, msg string, keysAndValues ...any)

StepError logs step execution error

func (*StepLogger) StepProgress

func (sl *StepLogger) StepProgress(msg string, keysAndValues ...any)

StepProgress logs step execution progress

func (*StepLogger) StepRetry

func (sl *StepLogger) StepRetry(attempt int, reason string, keysAndValues ...any)

StepRetry logs step retry

func (*StepLogger) StepStart

func (sl *StepLogger) StepStart(msg string, keysAndValues ...any)

StepStart logs step execution start

func (*StepLogger) StepSuccess

func (sl *StepLogger) StepSuccess(msg string, duration time.Duration, keysAndValues ...any)

StepSuccess logs step execution success

Jump to

Keyboard shortcuts

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