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 ¶
- type LogLevel
- type Logger
- func (l *Logger) WithContext(ctx context.Context) *Logger
- func (l *Logger) WithExecutionID(executionID string) *Logger
- func (l *Logger) WithField(key string, value interface{}) *Logger
- func (l *Logger) WithFields(fields map[string]interface{}) *Logger
- func (l *Logger) WithGraphID(graphID string) *Logger
- func (l *Logger) WithNodeID(nodeID string) *Logger
- type LoggerConfig
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 ¶
Logger wraps slog.Logger with additional convenience methods.
func NewDefaultLogger ¶
func NewDefaultLogger() *Logger
NewDefaultLogger creates a logger with INFO level and text format.
func NewLoggerFromConfig ¶
func NewLoggerFromConfig(cfg LoggerConfig) *Logger
NewLoggerFromConfig creates a logger from a configuration.
func (*Logger) WithContext ¶
WithContext returns a logger with context values added.
func (*Logger) WithExecutionID ¶
WithExecutionID returns a logger with the execution ID field.
func (*Logger) WithFields ¶
WithFields returns a logger with additional fields.
func (*Logger) WithGraphID ¶
WithGraphID returns a logger with the graph ID field.
func (*Logger) WithNodeID ¶
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.