operationlog

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware(service *OperationLogService, logger logging.Logger) func(next http.Handler) http.Handler

Middleware 创建操作日志记录中间件

func NewOperationLogModule

func NewOperationLogModule(logger logging.Logger, deps *core.Dependencies) core.Module

NewOperationLogModule creates a new operation log module

Types

type ClearInput

type ClearInput struct {
	RetentionDays int `json:"retentionDays"`
}

ClearInput defines parameters for clearing logs

type CreateLogInput

type CreateLogInput struct {
	RequestID     string
	Method        string
	Path          string
	QueryParams   string
	Body          string
	Status        int
	Latency       int64
	ClientIP      string
	UserAgent     string
	ErrorMessage  string
	UserID        *uuid.UUID
	OwnerDomainID *uuid.UUID
}

CreateLogInput 创建日志输入参数

type LogQueryInput

type LogQueryInput struct {
	Page      int
	PageSize  int
	StartDate *time.Time
	EndDate   *time.Time
	Method    string
	Path      string
	Status    *int
	UserID    *uuid.UUID
	ClientIP  string
	RequestID string
}

LogQueryInput 查询参数

type OperationLogHandler

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

func NewOperationLogHandler

func NewOperationLogHandler(service *OperationLogService, logger logging.Logger) *OperationLogHandler

func (*OperationLogHandler) Clear

Clear deletes old logs @Summary Clear old operation logs @Tags Logs @Accept json @Produce json @Param request body ClearInput true "Retention settings" @Success 200 {object} responder.Response @Router /logs/operations/clear [post]

func (*OperationLogHandler) Delete

Delete deletes a single log entry @Summary Delete operation log @Tags Logs @Param id path string true "Log ID" @Success 200 {object} responder.Response @Router /logs/operations/{id} [delete]

func (*OperationLogHandler) List

List returns a list of operation logs @Summary List operation logs @Tags Logs @Accept json @Produce json @Param page query int false "Page number" @Param pageSize query int false "Page size" @Param method query string false "HTTP Method" @Param status query int false "HTTP Status" @Param startDate query string false "Start date (RFC3339)" @Param endDate query string false "End date (RFC3339)" @Success 200 {object} responder.Response @Router /logs/operations [get]

type OperationLogModule

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

OperationLogModule manages the operation log module

func (*OperationLogModule) Middleware

func (m *OperationLogModule) Middleware(logger logging.Logger) func(http.Handler) http.Handler

Middleware returns the operation logging middleware

func (*OperationLogModule) Name

func (m *OperationLogModule) Name() string

func (*OperationLogModule) RegisterPrivateRoutes

func (m *OperationLogModule) RegisterPrivateRoutes(r chi.Router)

RegisterPrivateRoutes registers protected operation log endpoints

func (*OperationLogModule) RegisterPublicRoutes

func (m *OperationLogModule) RegisterPublicRoutes(r chi.Router)

RegisterPublicRoutes registers public operation log endpoints (none)

type OperationLogService

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

func NewOperationLogService

func NewOperationLogService(client *ent.Client, logger logging.Logger) *OperationLogService

func (*OperationLogService) ClearOldLogs

func (s *OperationLogService) ClearOldLogs(ctx context.Context, retentionDays int) (int, error)

ClearOldLogs deletes logs older than retention days

func (*OperationLogService) Create

func (s *OperationLogService) Create(input *CreateLogInput)

Create Asynchronously creates an operation log We use a separate context or background context to ensure log is saved even if request context is cancelled

func (*OperationLogService) Delete

func (s *OperationLogService) Delete(ctx context.Context, id uuid.UUID) error

Delete deletes a specific log entry

func (*OperationLogService) List

List queries operation logs with filters

Jump to

Keyboard shortcuts

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