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 ¶
- func EnableStepOutputLogging(enabled bool)
- func EnableVerboseLogging(enabled bool)
- func StepOutputLoggingEnabled() bool
- func VerboseLoggingEnabled() bool
- type CELLogger
- func (l *CELLogger) CacheHit(expression, expressionType string)
- func (l *CELLogger) EvaluationError(err error, expression, expressionType string, duration time.Duration)
- func (l *CELLogger) EvaluationStart(expression, expressionType string)
- func (l *CELLogger) EvaluationSuccess(expression, expressionType string, duration time.Duration, result any)
- type CleanupLogger
- type ControllerLogger
- func (cl *ControllerLogger) Error(err error, msg string, keysAndValues ...any)
- func (cl *ControllerLogger) Info(msg string, keysAndValues ...any)
- func (cl *ControllerLogger) Logr() logr.Logger
- func (cl *ControllerLogger) V(level int) logr.Logger
- func (cl *ControllerLogger) WithDuration(duration time.Duration) *ControllerLogger
- func (cl *ControllerLogger) WithEngram(engram *bubushv1alpha1.Engram) *ControllerLogger
- func (cl *ControllerLogger) WithError(err error) *ControllerLogger
- func (cl *ControllerLogger) WithImpulse(impulse *bubushv1alpha1.Impulse) *ControllerLogger
- func (cl *ControllerLogger) WithStepRun(steprun *runsv1alpha1.StepRun) *ControllerLogger
- func (cl *ControllerLogger) WithStory(story *bubushv1alpha1.Story) *ControllerLogger
- func (cl *ControllerLogger) WithStoryRun(srun *runsv1alpha1.StoryRun) *ControllerLogger
- func (cl *ControllerLogger) WithTransport(transport *transportv1alpha1.Transport) *ControllerLogger
- func (cl *ControllerLogger) WithValues(keysAndValues ...any) *ControllerLogger
- type LoggerKey
- type ReconcileLogger
- func (rl *ReconcileLogger) ReconcileError(err error, msg string, keysAndValues ...any)
- func (rl *ReconcileLogger) ReconcileRequeue(msg string, after time.Duration, keysAndValues ...any)
- func (rl *ReconcileLogger) ReconcileStart(msg string, keysAndValues ...any)
- func (rl *ReconcileLogger) ReconcileSuccess(msg string, keysAndValues ...any)
- type StepLogger
- func (sl *StepLogger) StepError(err error, msg string, keysAndValues ...any)
- func (sl *StepLogger) StepProgress(msg string, keysAndValues ...any)
- func (sl *StepLogger) StepRetry(attempt int, reason string, keysAndValues ...any)
- func (sl *StepLogger) StepStart(msg string, keysAndValues ...any)
- func (sl *StepLogger) StepSuccess(msg string, duration time.Duration, keysAndValues ...any)
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 ¶
NewCELLogger creates a new CELLogger from a base logger.
func (*CELLogger) EvaluationError ¶
func (l *CELLogger) EvaluationError(err error, expression, expressionType string, duration time.Duration)
EvaluationError logs a CEL evaluation error
func (*CELLogger) EvaluationStart ¶
EvaluationStart logs the start of a 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 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