logging

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package logging provides structured logging utilities using Go's standard slog package.

The Logger type wraps slog.Logger with convenience methods for adding common fields like execution_id, node_id, and graph_id. It supports both text and JSON output formats.

Example usage:

logger := logging.NewLogger(logging.LevelInfo, "json")
logger.Info("Starting execution", "graph_id", "my-graph")

// Add contextual fields
execLogger := logger.WithExecutionID("exec-123")
execLogger.Info("Node started", "node_id", "node-1")

Package logging provides structured logging utilities for DA Orchestrator.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogLevel

type LogLevel string

LogLevel represents the severity level of a log message.

const (
	// LevelDebug is for detailed debugging information.
	LevelDebug LogLevel = "debug"

	// LevelInfo is for general informational messages.
	LevelInfo LogLevel = "info"

	// LevelWarn is for warning messages.
	LevelWarn LogLevel = "warn"

	// LevelError is for error messages.
	LevelError LogLevel = "error"
)

type Logger

type Logger struct {
	*slog.Logger
}

Logger wraps slog.Logger with additional convenience methods.

func NewDefaultLogger

func NewDefaultLogger() *Logger

NewDefaultLogger creates a logger with INFO level and text format.

func NewLogger

func NewLogger(level LogLevel, format string) *Logger

NewLogger creates a new structured logger with the specified level and format.

func NewLoggerFromConfig

func NewLoggerFromConfig(cfg LoggerConfig) *Logger

NewLoggerFromConfig creates a logger from a configuration.

func (*Logger) WithContext

func (l *Logger) WithContext(ctx context.Context) *Logger

WithContext returns a logger with context values added.

func (*Logger) WithExecutionID

func (l *Logger) WithExecutionID(executionID string) *Logger

WithExecutionID returns a logger with the execution ID field.

func (*Logger) WithField

func (l *Logger) WithField(key string, value interface{}) *Logger

WithField returns a logger with an additional field.

func (*Logger) WithFields

func (l *Logger) WithFields(fields map[string]interface{}) *Logger

WithFields returns a logger with additional fields.

func (*Logger) WithGraphID

func (l *Logger) WithGraphID(graphID string) *Logger

WithGraphID returns a logger with the graph ID field.

func (*Logger) WithNodeID

func (l *Logger) WithNodeID(nodeID string) *Logger

WithNodeID returns a logger with the node ID field.

type LoggerConfig

type LoggerConfig struct {
	// Level is the minimum log level to output.
	Level LogLevel `json:"level"`

	// Format is the output format ("text" or "json").
	Format string `json:"format"`

	// AddSource adds source file and line number to log entries.
	AddSource bool `json:"add_source"`
}

LoggerConfig contains configuration for the logger.

func DefaultConfig

func DefaultConfig() LoggerConfig

DefaultConfig returns a default logger configuration.

Jump to

Keyboard shortcuts

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