Documentation
¶
Index ¶
- Constants
- type BatchLogEntry
- type ConnectionInfo
- type ConnectionStatus
- type LogEntry
- type LogEvent
- type LogEventType
- type LogFormat
- type LogLevel
- type LogOutput
- type LogQuery
- type LoggingConfig
- type LoggingError
- type LoggingFeature
- type LoggingOptions
- type LoggingProvider
- type LoggingStats
- type ProviderInfo
Constants ¶
const ( ErrCodeConnection = "CONNECTION_ERROR" ErrCodeTimeout = "TIMEOUT" ErrCodeInvalidLevel = "INVALID_LEVEL" ErrCodeInvalidFormat = "INVALID_FORMAT" ErrCodeSerialization = "SERIALIZATION_ERROR" ErrCodeDeserialization = "DESERIALIZATION_ERROR" ErrCodeQuota = "QUOTA_EXCEEDED" ErrCodeRetention = "RETENTION_ERROR" ErrCodeSearch = "SEARCH_ERROR" ErrCodeBatch = "BATCH_ERROR" )
Common logging error codes
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BatchLogEntry ¶
type BatchLogEntry struct {
Level LogLevel `json:"level"`
Message string `json:"message"`
Fields map[string]interface{} `json:"fields,omitempty"`
}
BatchLogEntry represents a batch log entry
type ConnectionInfo ¶
type ConnectionInfo struct {
Host string `json:"host"`
Port int `json:"port"`
Database string `json:"database"`
Username string `json:"username"`
Status ConnectionStatus `json:"status"`
Metadata map[string]string `json:"metadata"`
}
ConnectionInfo holds connection information for a logging provider
type ConnectionStatus ¶
type ConnectionStatus string
ConnectionStatus represents the connection status
const ( StatusConnected ConnectionStatus = "connected" StatusDisconnected ConnectionStatus = "disconnected" StatusConnecting ConnectionStatus = "connecting" StatusError ConnectionStatus = "error" )
type LogEntry ¶
type LogEntry struct {
Timestamp time.Time `json:"timestamp"`
Level LogLevel `json:"level"`
Message string `json:"message"`
Service string `json:"service"`
Version string `json:"version"`
TraceID string `json:"trace_id,omitempty"`
SpanID string `json:"span_id,omitempty"`
UserID string `json:"user_id,omitempty"`
TenantID string `json:"tenant_id,omitempty"`
RequestID string `json:"request_id,omitempty"`
IPAddress string `json:"ip_address,omitempty"`
UserAgent string `json:"user_agent,omitempty"`
Method string `json:"method,omitempty"`
Path string `json:"path,omitempty"`
StatusCode int `json:"status_code,omitempty"`
Duration int64 `json:"duration,omitempty"`
Error string `json:"error,omitempty"`
Fields map[string]interface{} `json:"fields,omitempty"`
Provider string `json:"provider"`
}
LogEntry represents a structured log entry
type LogEvent ¶
type LogEvent struct {
Type LogEventType `json:"type"`
Entry *LogEntry `json:"entry,omitempty"`
Timestamp time.Time `json:"timestamp"`
Provider string `json:"provider"`
}
LogEvent represents a logging event
type LogEventType ¶
type LogEventType string
LogEventType represents the type of logging event
const ( EventLog LogEventType = "log" EventError LogEventType = "error" EventWarning LogEventType = "warning" EventAlert LogEventType = "alert" EventStats LogEventType = "stats" )
type LogQuery ¶
type LogQuery struct {
Levels []LogLevel `json:"levels,omitempty"`
Services []string `json:"services,omitempty"`
StartTime *time.Time `json:"start_time,omitempty"`
EndTime *time.Time `json:"end_time,omitempty"`
Message string `json:"message,omitempty"`
Fields map[string]interface{} `json:"fields,omitempty"`
Limit int `json:"limit,omitempty"`
Offset int `json:"offset,omitempty"`
SortBy string `json:"sort_by,omitempty"`
SortOrder string `json:"sort_order,omitempty"`
}
LogQuery represents a log search query
type LoggingConfig ¶
type LoggingConfig struct {
Level LogLevel `json:"level"`
Format LogFormat `json:"format"`
Output LogOutput `json:"output"`
Service string `json:"service"`
Version string `json:"version"`
Index string `json:"index"`
Retention time.Duration `json:"retention"`
Compression bool `json:"compression"`
Encryption bool `json:"encryption"`
Metadata map[string]interface{} `json:"metadata"`
}
LoggingConfig holds logging configuration
func GetDefaultConfig ¶
func GetDefaultConfig() *LoggingConfig
GetDefaultConfig returns default logging configuration
type LoggingError ¶
type LoggingError struct {
Code string `json:"code"`
Message string `json:"message"`
Level LogLevel `json:"level,omitempty"`
}
LoggingError represents a logging-specific error
func (*LoggingError) Error ¶
func (e *LoggingError) Error() string
type LoggingFeature ¶
type LoggingFeature string
LoggingFeature represents a logging feature
const ( // Basic features FeatureBasicLogging LoggingFeature = "basic_logging" FeatureStructuredLog LoggingFeature = "structured_log" FeatureFormattedLog LoggingFeature = "formatted_log" FeatureContextLogging LoggingFeature = "context_logging" FeatureBatchLogging LoggingFeature = "batch_logging" // Advanced features FeatureSearch LoggingFeature = "search" FeatureFiltering LoggingFeature = "filtering" FeatureAggregation LoggingFeature = "aggregation" FeatureRetention LoggingFeature = "retention" FeatureCompression LoggingFeature = "compression" FeatureEncryption LoggingFeature = "encryption" FeatureReplication LoggingFeature = "replication" FeatureClustering LoggingFeature = "clustering" FeatureRealTime LoggingFeature = "real_time" FeatureAlerting LoggingFeature = "alerting" FeatureDashboards LoggingFeature = "dashboards" FeatureMetrics LoggingFeature = "metrics" FeatureTracing LoggingFeature = "tracing" )
type LoggingOptions ¶
type LoggingOptions struct {
Provider string `json:"provider"`
ConfigPath string `json:"config_path"`
Environment string `json:"environment"`
WatchChanges bool `json:"watch_changes"`
Metadata map[string]string `json:"metadata"`
}
LoggingOptions represents logging options
type LoggingProvider ¶
type LoggingProvider interface {
// Provider information
GetName() string
GetSupportedFeatures() []LoggingFeature
GetConnectionInfo() *ConnectionInfo
// Connection management
Connect(ctx context.Context) error
Disconnect(ctx context.Context) error
Ping(ctx context.Context) error
IsConnected() bool
// Basic logging operations
Log(ctx context.Context, level LogLevel, message string, fields map[string]interface{}) error
LogWithContext(ctx context.Context, level LogLevel, message string, fields map[string]interface{}) error
// Structured logging
Info(ctx context.Context, message string, fields ...map[string]interface{}) error
Debug(ctx context.Context, message string, fields ...map[string]interface{}) error
Warn(ctx context.Context, message string, fields ...map[string]interface{}) error
Error(ctx context.Context, message string, fields ...map[string]interface{}) error
Fatal(ctx context.Context, message string, fields ...map[string]interface{}) error
Panic(ctx context.Context, message string, fields ...map[string]interface{}) error
// Formatted logging
Infof(ctx context.Context, format string, args ...interface{}) error
Debugf(ctx context.Context, format string, args ...interface{}) error
Warnf(ctx context.Context, format string, args ...interface{}) error
Errorf(ctx context.Context, format string, args ...interface{}) error
Fatalf(ctx context.Context, format string, args ...interface{}) error
Panicf(ctx context.Context, format string, args ...interface{}) error
// Advanced operations
WithFields(ctx context.Context, fields map[string]interface{}) LoggingProvider
WithField(ctx context.Context, key string, value interface{}) LoggingProvider
WithError(ctx context.Context, err error) LoggingProvider
WithContext(ctx context.Context) LoggingProvider
// Batch operations
LogBatch(ctx context.Context, entries []LogEntry) error
// Query and search
Search(ctx context.Context, query LogQuery) ([]LogEntry, error)
GetStats(ctx context.Context) (*LoggingStats, error)
}
LoggingProvider represents a logging provider interface
type LoggingStats ¶
type LoggingStats struct {
TotalLogs int64 `json:"total_logs"`
LogsByLevel map[LogLevel]int64 `json:"logs_by_level"`
LogsByService map[string]int64 `json:"logs_by_service"`
StorageSize int64 `json:"storage_size"`
Uptime time.Duration `json:"uptime"`
LastUpdate time.Time `json:"last_update"`
Provider string `json:"provider"`
}
LoggingStats represents logging statistics
type ProviderInfo ¶
type ProviderInfo struct {
Name string `json:"name"`
SupportedFeatures []LoggingFeature `json:"supported_features"`
ConnectionInfo *ConnectionInfo `json:"connection_info"`
IsConnected bool `json:"is_connected"`
}
ProviderInfo holds information about a logging provider