Documentation
¶
Index ¶
- Constants
- func BuiltInLoggingProfileNames() []string
- func EncodeLoggingProfileEvent(config LoggingProfileConfig, environment map[string]string, ...) (map[string]any, error)
- func EncodeLoggingProfileEventWithSanitizer(config LoggingProfileConfig, environment map[string]string, ...) (map[string]any, error)
- func HooksFromLogger(logger StructuredLogger) apptheory.ObservabilityHooks
- func LoggingProfileCatalog() map[string]any
- func LoggingProfileValidationErrors(config LoggingProfileConfig) []string
- func ValidateLoggingProfile(config LoggingProfileConfig) error
- type ErrorNotifier
- type LogEntry
- type LoggerConfig
- type LoggerFactory
- type LoggerStats
- type LoggingProfileAlertingHints
- type LoggingProfileConfig
- type LoggingProfileEncoding
- type LoggingProfileEnrichment
- type LoggingProfileError
- type LoggingProfileErrorCapture
- type LoggingProfileEvent
- type LoggingProfileJobContext
- type LoggingProfileRequestContext
- type LoggingProfileSanitization
- type LoggingProfileValidationError
- type ProfileLogger
- func (l *ProfileLogger) Close() error
- func (l *ProfileLogger) Debug(message string, fields ...map[string]any)
- func (l *ProfileLogger) Entries() []map[string]any
- func (l *ProfileLogger) Error(message string, fields ...map[string]any)
- func (l *ProfileLogger) Flush(_ context.Context) error
- func (l *ProfileLogger) GetStats() LoggerStats
- func (l *ProfileLogger) Info(message string, fields ...map[string]any)
- func (l *ProfileLogger) IsHealthy() bool
- func (l *ProfileLogger) Warn(message string, fields ...map[string]any)
- func (l *ProfileLogger) WithField(key string, value any) StructuredLogger
- func (l *ProfileLogger) WithFields(fields map[string]any) StructuredLogger
- func (l *ProfileLogger) WithRequestID(requestID string) StructuredLogger
- func (l *ProfileLogger) WithSpanID(spanID string) StructuredLogger
- func (l *ProfileLogger) WithTenantID(tenantID string) StructuredLogger
- func (l *ProfileLogger) WithTraceID(traceID string) StructuredLogger
- func (l *ProfileLogger) WithUserID(userID string) StructuredLogger
- type ProfileLoggerOption
- type SanitizerFunc
- type StructuredLogger
- type TestLogger
- func (l *TestLogger) Close() error
- func (l *TestLogger) Debug(message string, fields ...map[string]any)
- func (l *TestLogger) Entries() []LogEntry
- func (l *TestLogger) Error(message string, fields ...map[string]any)
- func (l *TestLogger) Flush(ctx context.Context) error
- func (l *TestLogger) GetStats() LoggerStats
- func (l *TestLogger) Info(message string, fields ...map[string]any)
- func (l *TestLogger) IsHealthy() bool
- func (l *TestLogger) Warn(message string, fields ...map[string]any)
- func (l *TestLogger) WithField(key string, value any) StructuredLogger
- func (l *TestLogger) WithFields(fields map[string]any) StructuredLogger
- func (l *TestLogger) WithRequestID(requestID string) StructuredLogger
- func (l *TestLogger) WithSpanID(spanID string) StructuredLogger
- func (l *TestLogger) WithTenantID(tenantID string) StructuredLogger
- func (l *TestLogger) WithTraceID(traceID string) StructuredLogger
- func (l *TestLogger) WithUserID(userID string) StructuredLogger
Constants ¶
const ( LoggingProfilePayTheoryAlertV1 = "paytheory-alert-v1" LoggingProfileCloudWatchJSON = "cloudwatch-json" LoggingProfileLegacy = "legacy" LoggingProfileLocalDev = "local-dev" )
const LoggingProfileSchemaVersion = "apptheory.logging/v1"
Variables ¶
This section is empty.
Functions ¶
func BuiltInLoggingProfileNames ¶ added in v1.7.1
func BuiltInLoggingProfileNames() []string
func EncodeLoggingProfileEvent ¶ added in v1.7.1
func EncodeLoggingProfileEvent(config LoggingProfileConfig, environment map[string]string, event LoggingProfileEvent) (map[string]any, error)
func EncodeLoggingProfileEventWithSanitizer ¶ added in v1.7.1
func EncodeLoggingProfileEventWithSanitizer(config LoggingProfileConfig, environment map[string]string, event LoggingProfileEvent, sanitizerFn SanitizerFunc) (map[string]any, error)
func HooksFromLogger ¶
func HooksFromLogger(logger StructuredLogger) apptheory.ObservabilityHooks
func LoggingProfileCatalog ¶ added in v1.7.1
func LoggingProfileValidationErrors ¶ added in v1.7.1
func LoggingProfileValidationErrors(config LoggingProfileConfig) []string
func ValidateLoggingProfile ¶ added in v1.7.1
func ValidateLoggingProfile(config LoggingProfileConfig) error
Types ¶
type ErrorNotifier ¶
type LogEntry ¶
type LogEntry struct {
Timestamp time.Time `json:"timestamp"`
Level string `json:"level"`
Message string `json:"message"`
Fields map[string]any `json:"fields,omitempty"`
RequestID string `json:"request_id,omitempty"`
TenantID string `json:"tenant_id,omitempty"`
UserID string `json:"user_id,omitempty"`
TraceID string `json:"trace_id,omitempty"`
SpanID string `json:"span_id,omitempty"`
}
LogEntry represents a structured log entry.
This type is intentionally small and stable so implementations can adapt it to their backend.
type LoggerConfig ¶
type LoggerConfig struct {
Format string `json:"format"`
Level string `json:"level"`
RetryDelay time.Duration `json:"retry_delay"`
BatchSize int `json:"batch_size"`
BufferSize int `json:"buffer_size"`
MaxRetries int `json:"max_retries"`
EnableStack bool `json:"enable_stack"`
EnableCaller bool `json:"enable_caller"`
SanitizationPolicy *sanitization.Policy `json:"sanitization,omitempty"`
}
LoggerConfig configures logger implementations.
Fields are intentionally aligned with Lift’s `observability.LoggerConfig` where it matters for migrations.
type LoggerFactory ¶
type LoggerFactory interface {
CreateConsoleLogger(config LoggerConfig) (StructuredLogger, error)
CreateTestLogger() StructuredLogger
CreateNoOpLogger() StructuredLogger
}
type LoggerStats ¶
type LoggerStats struct {
LastFlush time.Time `json:"last_flush"`
LastError string `json:"last_error,omitempty"`
EntriesLogged int64 `json:"entries_logged"`
EntriesDropped int64 `json:"entries_dropped"`
FlushCount int64 `json:"flush_count"`
ErrorCount int64 `json:"error_count"`
AverageFlush time.Duration `json:"average_flush_time"`
}
type LoggingProfileAlertingHints ¶ added in v1.7.1
type LoggingProfileConfig ¶ added in v1.7.1
type LoggingProfileConfig struct {
SchemaVersion string `json:"schema_version" yaml:"schema_version"`
Profile string `json:"profile" yaml:"profile"`
Encoding LoggingProfileEncoding `json:"encoding" yaml:"encoding"`
Levels map[string]string `json:"levels,omitempty" yaml:"levels,omitempty"`
RequiredFields []string `json:"required_fields,omitempty" yaml:"required_fields,omitempty"`
RecommendedFields []string `json:"recommended_fields,omitempty" yaml:"recommended_fields,omitempty"`
FieldMap map[string]string `json:"field_map,omitempty" yaml:"field_map,omitempty"`
Enrichment LoggingProfileEnrichment `json:"enrichment,omitempty" yaml:"enrichment,omitempty"`
ErrorCapture LoggingProfileErrorCapture `json:"error_capture,omitempty" yaml:"error_capture,omitempty"`
Sanitization LoggingProfileSanitization `json:"sanitization,omitempty" yaml:"sanitization,omitempty"`
AlertingHints LoggingProfileAlertingHints `json:"alerting_hints,omitempty" yaml:"alerting_hints,omitempty"`
}
func DecodeLoggingProfileJSON ¶ added in v1.7.1
func DecodeLoggingProfileJSON(raw []byte) (LoggingProfileConfig, error)
func DecodeLoggingProfileYAML ¶ added in v1.7.1
func DecodeLoggingProfileYAML(raw []byte) (LoggingProfileConfig, error)
func DefaultLoggingProfile ¶ added in v1.7.1
func DefaultLoggingProfile(profile string) (LoggingProfileConfig, error)
type LoggingProfileEncoding ¶ added in v1.7.1
type LoggingProfileEncoding struct {
Format string `json:"format" yaml:"format"`
TimestampField string `json:"timestamp_field,omitempty" yaml:"timestamp_field,omitempty"`
TimestampFormat string `json:"timestamp_format,omitempty" yaml:"timestamp_format,omitempty"`
LevelField string `json:"level_field,omitempty" yaml:"level_field,omitempty"`
MessageField string `json:"message_field,omitempty" yaml:"message_field,omitempty"`
}
type LoggingProfileEnrichment ¶ added in v1.7.1
type LoggingProfileError ¶ added in v1.7.1
type LoggingProfileErrorCapture ¶ added in v1.7.1
type LoggingProfileErrorCapture struct {
IncludeErrorType bool `json:"include_error_type" yaml:"include_error_type"`
IncludeErrorCode bool `json:"include_error_code" yaml:"include_error_code"`
IncludeStackTrace bool `json:"include_stack_trace" yaml:"include_stack_trace"`
StackTraceField string `json:"stack_trace_field,omitempty" yaml:"stack_trace_field,omitempty"`
StackHashField string `json:"stack_hash_field,omitempty" yaml:"stack_hash_field,omitempty"`
StackHashAlgorithm string `json:"stack_hash_algorithm,omitempty" yaml:"stack_hash_algorithm,omitempty"`
}
type LoggingProfileEvent ¶ added in v1.7.1
type LoggingProfileEvent struct {
Timestamp time.Time `json:"timestamp"`
Level string `json:"level"`
Event string `json:"event,omitempty"`
Message string `json:"message"`
NormalizedMessage string `json:"normalized_message,omitempty"`
Request LoggingProfileRequestContext `json:"request,omitempty"`
Job LoggingProfileJobContext `json:"job,omitempty"`
Error LoggingProfileError `json:"error,omitempty"`
Fields map[string]any `json:"fields,omitempty"`
}
type LoggingProfileJobContext ¶ added in v1.7.1
type LoggingProfileJobContext struct {
Name string `json:"name,omitempty"`
}
type LoggingProfileRequestContext ¶ added in v1.7.1
type LoggingProfileRequestContext struct {
RequestID string `json:"request_id,omitempty"`
TenantID string `json:"tenant_id,omitempty"`
UserID string `json:"user_id,omitempty"`
TraceID string `json:"trace_id,omitempty"`
SpanID string `json:"span_id,omitempty"`
CorrelationID string `json:"correlation_id,omitempty"`
Route string `json:"route,omitempty"`
Method string `json:"method,omitempty"`
Path string `json:"path,omitempty"`
Status int `json:"status,omitempty"`
}
type LoggingProfileSanitization ¶ added in v1.7.1
type LoggingProfileValidationError ¶ added in v1.7.1
type LoggingProfileValidationError struct {
Errors []string
}
func (*LoggingProfileValidationError) Error ¶ added in v1.7.1
func (e *LoggingProfileValidationError) Error() string
type ProfileLogger ¶ added in v1.7.1
type ProfileLogger struct {
// contains filtered or unexported fields
}
func HooksFromProfileLogger ¶ added in v1.7.1
func HooksFromProfileLogger(config LoggingProfileConfig, options ...ProfileLoggerOption) (apptheory.ObservabilityHooks, *ProfileLogger, error)
func NewProfileLogger ¶ added in v1.7.1
func NewProfileLogger(config LoggingProfileConfig, options ...ProfileLoggerOption) (*ProfileLogger, error)
func (*ProfileLogger) Close ¶ added in v1.7.1
func (l *ProfileLogger) Close() error
func (*ProfileLogger) Debug ¶ added in v1.7.1
func (l *ProfileLogger) Debug(message string, fields ...map[string]any)
func (*ProfileLogger) Entries ¶ added in v1.7.1
func (l *ProfileLogger) Entries() []map[string]any
func (*ProfileLogger) Error ¶ added in v1.7.1
func (l *ProfileLogger) Error(message string, fields ...map[string]any)
func (*ProfileLogger) Flush ¶ added in v1.7.1
func (l *ProfileLogger) Flush(_ context.Context) error
func (*ProfileLogger) GetStats ¶ added in v1.7.1
func (l *ProfileLogger) GetStats() LoggerStats
func (*ProfileLogger) Info ¶ added in v1.7.1
func (l *ProfileLogger) Info(message string, fields ...map[string]any)
func (*ProfileLogger) IsHealthy ¶ added in v1.7.1
func (l *ProfileLogger) IsHealthy() bool
func (*ProfileLogger) Warn ¶ added in v1.7.1
func (l *ProfileLogger) Warn(message string, fields ...map[string]any)
func (*ProfileLogger) WithField ¶ added in v1.7.1
func (l *ProfileLogger) WithField(key string, value any) StructuredLogger
func (*ProfileLogger) WithFields ¶ added in v1.7.1
func (l *ProfileLogger) WithFields(fields map[string]any) StructuredLogger
func (*ProfileLogger) WithRequestID ¶ added in v1.7.1
func (l *ProfileLogger) WithRequestID(requestID string) StructuredLogger
func (*ProfileLogger) WithSpanID ¶ added in v1.7.1
func (l *ProfileLogger) WithSpanID(spanID string) StructuredLogger
func (*ProfileLogger) WithTenantID ¶ added in v1.7.1
func (l *ProfileLogger) WithTenantID(tenantID string) StructuredLogger
func (*ProfileLogger) WithTraceID ¶ added in v1.7.1
func (l *ProfileLogger) WithTraceID(traceID string) StructuredLogger
func (*ProfileLogger) WithUserID ¶ added in v1.7.1
func (l *ProfileLogger) WithUserID(userID string) StructuredLogger
type ProfileLoggerOption ¶ added in v1.7.1
type ProfileLoggerOption func(*profileLoggerOptions)
func WithProfileClock ¶ added in v1.7.1
func WithProfileClock(clock func() time.Time) ProfileLoggerOption
func WithProfileEnvironment ¶ added in v1.7.1
func WithProfileEnvironment(environment map[string]string) ProfileLoggerOption
func WithProfileSanitizer ¶ added in v1.7.1
func WithProfileSanitizer(fn SanitizerFunc) ProfileLoggerOption
func WithProfileWriter ¶ added in v1.7.1
func WithProfileWriter(writer io.Writer) ProfileLoggerOption
type SanitizerFunc ¶
type StructuredLogger ¶
type StructuredLogger interface {
Debug(message string, fields ...map[string]any)
Info(message string, fields ...map[string]any)
Warn(message string, fields ...map[string]any)
Error(message string, fields ...map[string]any)
WithField(key string, value any) StructuredLogger
WithFields(fields map[string]any) StructuredLogger
WithRequestID(requestID string) StructuredLogger
WithTenantID(tenantID string) StructuredLogger
WithUserID(userID string) StructuredLogger
WithTraceID(traceID string) StructuredLogger
WithSpanID(spanID string) StructuredLogger
Flush(ctx context.Context) error
Close() error
IsHealthy() bool
GetStats() LoggerStats
}
StructuredLogger is the primary Go logging surface used by Pay Theory migrations.
It intentionally mirrors the Lift logger API shape (message + map fields) while allowing implementations to provide stronger guarantees (sanitization, health, lifecycle).
func NewNoOpLogger ¶
func NewNoOpLogger() StructuredLogger
type TestLogger ¶
type TestLogger struct {
// contains filtered or unexported fields
}
TestLogger is an in-memory logger implementation for deterministic unit tests.
Derived loggers (via With* calls) share the same underlying core.
func NewTestLogger ¶
func NewTestLogger() *TestLogger
func (*TestLogger) Close ¶
func (l *TestLogger) Close() error
func (*TestLogger) Entries ¶
func (l *TestLogger) Entries() []LogEntry
func (*TestLogger) GetStats ¶
func (l *TestLogger) GetStats() LoggerStats
func (*TestLogger) IsHealthy ¶
func (l *TestLogger) IsHealthy() bool
func (*TestLogger) WithField ¶
func (l *TestLogger) WithField(key string, value any) StructuredLogger
func (*TestLogger) WithFields ¶
func (l *TestLogger) WithFields(fields map[string]any) StructuredLogger
func (*TestLogger) WithRequestID ¶
func (l *TestLogger) WithRequestID(requestID string) StructuredLogger
func (*TestLogger) WithSpanID ¶
func (l *TestLogger) WithSpanID(spanID string) StructuredLogger
func (*TestLogger) WithTenantID ¶
func (l *TestLogger) WithTenantID(tenantID string) StructuredLogger
func (*TestLogger) WithTraceID ¶
func (l *TestLogger) WithTraceID(traceID string) StructuredLogger
func (*TestLogger) WithUserID ¶
func (l *TestLogger) WithUserID(userID string) StructuredLogger