postgres

package
v1.5.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2025 License: BSL-1.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTenantIDFromString

func GetTenantIDFromString(tenantIDStr string) (int, error)

GetTenantIDFromString converts string tenant ID to integer

func SanitizeForLog

func SanitizeForLog(data map[string]any) map[string]any

SanitizeForLog removes sensitive information from data before logging

Types

type ErrorInfo

type ErrorInfo struct {
	Code    string `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
}

ErrorInfo represents error details

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger handles PostgreSQL logging operations

func NewLogger

func NewLogger(db *conn.DB) *Logger

NewLogger creates a new PostgreSQL logger

func (*Logger) GetActiveProviders added in v1.5.9

func (l *Logger) GetActiveProviders(ctx context.Context) ([]map[string]any, error)

GetActiveProviders retrieves providers that have tenant configurations

func (*Logger) GetAllProvidersStats

func (l *Logger) GetAllProvidersStats(ctx context.Context, tenantID int, hours int) (map[string]map[string]any, error)

GetAllProvidersStats retrieves stats for all providers for a tenant

func (*Logger) GetAllRecentActivity added in v1.5.9

func (l *Logger) GetAllRecentActivity(ctx context.Context, limit int) ([]map[string]any, error)

GetAllRecentActivity retrieves recent payment activity from all provider tables

func (*Logger) GetAllTenants added in v1.5.9

func (l *Logger) GetAllTenants(ctx context.Context) ([]map[string]any, error)

GetAllTenants retrieves all tenants with id and username from the database

func (*Logger) GetPaymentStats

func (l *Logger) GetPaymentStats(ctx context.Context, tenantID int, provider string, hours int) (map[string]any, error)

GetPaymentStats retrieves payment statistics for a provider

func (*Logger) GetPaymentStatsComparison

func (l *Logger) GetPaymentStatsComparison(ctx context.Context, tenantID int, provider string, currentHours, previousHours int) (map[string]any, error)

GetPaymentStatsComparison retrieves payment statistics comparison between two periods

func (*Logger) GetPaymentTrends

func (l *Logger) GetPaymentTrends(ctx context.Context, tenantID int, provider string, hours int) (map[string]any, error)

GetPaymentTrends retrieves hourly payment trends for analytics

func (*Logger) GetPaymentTrendsMonthly added in v1.5.9

func (l *Logger) GetPaymentTrendsMonthly(ctx context.Context, tenantID int, provider string, month, year int) (map[string]any, error)

GetPaymentTrendsMonthly retrieves daily payment trends for a specific month/year

func (*Logger) LogPaymentRequest

func (l *Logger) LogPaymentRequest(ctx context.Context, logEntry PaymentLog) error

LogPaymentRequest logs a payment request to PostgreSQL

func (*Logger) LogSystemEvent

func (l *Logger) LogSystemEvent(ctx context.Context, logEntry SystemLog) error

LogSystemEvent logs a system event to PostgreSQL

func (*Logger) SearchPaymentByID added in v1.5.9

func (l *Logger) SearchPaymentByID(ctx context.Context, tenantID int, provider, paymentID string) ([]map[string]any, error)

SearchPaymentByID searches for a specific payment by ID in a provider table

func (*Logger) SearchPaymentLogs

func (l *Logger) SearchPaymentLogs(ctx context.Context, tenantID int, provider string, filters map[string]any) ([]PaymentLog, error)

SearchPaymentLogs searches for payment logs based on criteria

func (*Logger) SearchSystemLogs

func (l *Logger) SearchSystemLogs(ctx context.Context, filters map[string]any) ([]SystemLog, error)

SearchSystemLogs searches for system logs based on criteria

type PaymentInfo

type PaymentInfo struct {
	PaymentID     string  `json:"payment_id,omitempty"`
	Amount        float64 `json:"amount,omitempty"`
	Currency      string  `json:"currency,omitempty"`
	CustomerEmail string  `json:"customer_email,omitempty"`
	Status        string  `json:"status,omitempty"`
	Use3D         bool    `json:"use_3d,omitempty"`
}

PaymentInfo represents payment-specific information

type PaymentLog

type PaymentLog struct {
	ID           int64          `json:"id,omitempty"`
	Timestamp    time.Time      `json:"timestamp"`
	TenantID     int            `json:"tenant_id,omitempty"`
	Provider     string         `json:"provider"`
	Method       string         `json:"method"`
	Endpoint     string         `json:"endpoint"`
	RequestID    string         `json:"request_id"`
	UserAgent    string         `json:"user_agent,omitempty"`
	ClientIP     string         `json:"client_ip,omitempty"`
	Request      map[string]any `json:"request"`
	Response     map[string]any `json:"response"`
	PaymentInfo  *PaymentInfo   `json:"payment_info,omitempty"`
	Error        *ErrorInfo     `json:"error,omitempty"`
	ProcessingMs int64          `json:"processing_ms"`
}

PaymentLog represents a structured payment log entry

type SystemLog

type SystemLog struct {
	ID        int64          `json:"id,omitempty"`
	Level     string         `json:"level"`
	Message   string         `json:"message"`
	Component string         `json:"component,omitempty"`
	TenantID  *int           `json:"tenant_id,omitempty"`
	Data      map[string]any `json:"data,omitempty"`
	CreatedAt time.Time      `json:"created_at"`
}

SystemLog represents a structured system log entry

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL