Documentation
¶
Index ¶
- type LogEntry
- type Logger
- type MockLogger
- func (m *MockLogger) Debug(ctx context.Context, message string)
- func (m *MockLogger) Debugf(ctx context.Context, format string, args ...interface{})
- func (m *MockLogger) Error(ctx context.Context, message string)
- func (m *MockLogger) Errorf(ctx context.Context, format string, args ...interface{})
- func (m *MockLogger) GetLogs() []LogEntry
- func (m *MockLogger) Info(ctx context.Context, message string)
- func (m *MockLogger) Infof(ctx context.Context, format string, args ...interface{})
- func (m *MockLogger) Warn(ctx context.Context, message string)
- func (m *MockLogger) Warnf(ctx context.Context, format string, args ...interface{})
- type OutputFormat
- type WatermillLoggerAdapter
- func (w *WatermillLoggerAdapter) Debug(msg string, fields watermill.LogFields)
- func (w *WatermillLoggerAdapter) Error(msg string, err error, fields watermill.LogFields)
- func (w *WatermillLoggerAdapter) Info(msg string, fields watermill.LogFields)
- func (w *WatermillLoggerAdapter) Trace(msg string, fields watermill.LogFields)
- func (w *WatermillLoggerAdapter) With(fields watermill.LogFields) watermill.LoggerAdapter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Logger ¶
type Logger interface {
// Debug logs at debug level
Debug(ctx context.Context, message string)
// Debugf logs at debug level with formatting
Debugf(ctx context.Context, format string, args ...interface{})
// Info logs at info level
Info(ctx context.Context, message string)
// Infof logs at info level with formatting
Infof(ctx context.Context, format string, args ...interface{})
// Warn logs at warn level
Warn(ctx context.Context, message string)
// Warnf logs at warn level with formatting
Warnf(ctx context.Context, format string, args ...interface{})
// Error logs at error level
Error(ctx context.Context, message string)
// Errorf logs at error level with formatting
Errorf(ctx context.Context, format string, args ...interface{})
}
Logger defines the interface for structured logging that callers should provide. This matches the logger interface from hyperfleet-adapter/pkg/logger.
func NewTestLogger ¶
func NewTestLogger(format ...OutputFormat) Logger
NewTestLogger creates a logger for testing and examples. Production applications should implement the Logger interface with their own logging infrastructure. If no format is specified, defaults to text format.
type MockLogger ¶
type MockLogger struct {
// contains filtered or unexported fields
}
MockLogger implements the Logger interface for testing
func NewMockLogger ¶
func NewMockLogger() *MockLogger
func (*MockLogger) Debugf ¶
func (m *MockLogger) Debugf(ctx context.Context, format string, args ...interface{})
func (*MockLogger) Errorf ¶
func (m *MockLogger) Errorf(ctx context.Context, format string, args ...interface{})
func (*MockLogger) GetLogs ¶
func (m *MockLogger) GetLogs() []LogEntry
type OutputFormat ¶
type OutputFormat int
OutputFormat defines the log output format
const ( FormatText OutputFormat = iota // Default text format FormatJSON // JSON format )
type WatermillLoggerAdapter ¶
type WatermillLoggerAdapter struct {
// contains filtered or unexported fields
}
WatermillLoggerAdapter adapts the caller's Logger interface to Watermill's LoggerAdapter interface. It stores the context from broker operations and uses it when Watermill calls logging methods.
func NewWatermillLoggerAdapter ¶
func NewWatermillLoggerAdapter(logger Logger, ctx context.Context) *WatermillLoggerAdapter
NewWatermillLoggerAdapter creates a new adapter that converts the caller's Logger to Watermill's LoggerAdapter interface, preserving the provided context. The context is immutable after construction to ensure thread safety.
func (*WatermillLoggerAdapter) Debug ¶
func (w *WatermillLoggerAdapter) Debug(msg string, fields watermill.LogFields)
Debug logs a debug message with optional fields. Implements watermill.LoggerAdapter interface.
func (*WatermillLoggerAdapter) Error ¶
func (w *WatermillLoggerAdapter) Error(msg string, err error, fields watermill.LogFields)
Error logs an error message with optional fields. Implements watermill.LoggerAdapter interface.
func (*WatermillLoggerAdapter) Info ¶
func (w *WatermillLoggerAdapter) Info(msg string, fields watermill.LogFields)
Info logs an info message with optional fields. Implements watermill.LoggerAdapter interface.
func (*WatermillLoggerAdapter) Trace ¶
func (w *WatermillLoggerAdapter) Trace(msg string, fields watermill.LogFields)
Trace logs a trace message with optional fields. Implements watermill.LoggerAdapter interface. Note: Since the caller's Logger interface doesn't have Trace level, we map this to Debug level.
func (*WatermillLoggerAdapter) With ¶
func (w *WatermillLoggerAdapter) With(fields watermill.LogFields) watermill.LoggerAdapter
With creates a new logger adapter with additional fields. Implements watermill.LoggerAdapter interface. Returns a new adapter that preserves and merges the incoming fields with existing fields. Incoming fields override existing fields on key collision. The original adapter is not modified, ensuring concurrency safety.