Documentation
¶
Index ¶
- Constants
- func NewContextWithLogger(ctx context.Context, logger Logger) context.Context
- type Field
- func ClientID(value string) Field
- func DatasourceAddress(value string) Field
- func DatasourceID(value string) Field
- func DatasourceType(value string) Field
- func EntityExternalID(value string) Field
- func EntityID(value string) Field
- func RequestCursor(value any) Field
- func RequestPageSize(value int64) Field
- func TenantID(value string) Field
- type LogEntry
- type Logger
- type MockLogger
- func (m *MockLogger) Debug(msg string, fields ...Field)
- func (m *MockLogger) Entries() []LogEntry
- func (m *MockLogger) Error(msg string, fields ...Field)
- func (m *MockLogger) Fields() []Field
- func (m *MockLogger) Info(msg string, fields ...Field)
- func (m *MockLogger) Reset()
- func (m *MockLogger) With(fields ...Field) Logger
Constants ¶
const ( FieldClientID = "clientId" FieldDatasourceAddress = "datasourceAddress" FieldDatasourceID = "datasourceId" FieldDatasourceType = "datasourceType" FieldEntityExternalID = "entityExternalId" FieldEntityID = "entityId" FieldAdapterRequestCursor = "adapterRequestCursor" // Prefix with "adapter" because there may be multiple page cursors used in a single adapter request. FieldAdapterRequestPageSize = "adapterRequestPageSize" FieldTenantID = "tenantId" )
Log field constants.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Field ¶
Field represents a key-value pair for structured logging.
func DatasourceAddress ¶
DatasourceAddress returns a log field for the datasource address.
func DatasourceID ¶
DatasourceID returns a log field for the datasource ID.
func DatasourceType ¶
DatasourceType returns a log field for the datasource type.
func EntityExternalID ¶
EntityExternalID returns a log field for the entity external ID.
func RequestCursor ¶
RequestCursor returns a log field for the request cursor.
func RequestPageSize ¶
RequestPageSize returns a log field for the request page size.
type Logger ¶
type Logger interface {
// Info logs an informational message with optional fields.
Info(msg string, fields ...Field)
// Error logs an error message with optional fields.
Error(msg string, fields ...Field)
// Debug logs a debug message with optional fields.
Debug(msg string, fields ...Field)
// With creates a child logger with the given fields pre-attached.
With(fields ...Field) Logger
}
Logger is a minimal interface for structured logging.
func FromContext ¶
FromContext retrieves the logger from the context. If no logger is found in the context or the value is not a logger, it returns nil.
type MockLogger ¶
type MockLogger struct {
// contains filtered or unexported fields
}
MockLogger is a test implementation of the Logger interface. It records all log calls for verification in tests.
func (*MockLogger) Debug ¶
func (m *MockLogger) Debug(msg string, fields ...Field)
Debug logs a debug message.
func (*MockLogger) Entries ¶
func (m *MockLogger) Entries() []LogEntry
Entries returns all logged entries.
func (*MockLogger) Error ¶
func (m *MockLogger) Error(msg string, fields ...Field)
Error logs an error message.
func (*MockLogger) Fields ¶
func (m *MockLogger) Fields() []Field
Fields returns all pre-attached fields.
func (*MockLogger) Info ¶
func (m *MockLogger) Info(msg string, fields ...Field)
Info logs an informational message.
func (*MockLogger) With ¶
func (m *MockLogger) With(fields ...Field) Logger
With creates a child logger with pre-attached fields.