log

package
v0.27.4 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CreateBuildIDIndex represents a query to create an
	// index on the logs table for the build_id column.
	CreateBuildIDIndex = `
CREATE INDEX
IF NOT EXISTS
logs_build_id
ON logs (build_id);
`

	// CreateCreatedAtIndex represents a query to create an
	// index on the logs table for the created_at column.
	CreateCreatedAtIndex = `
CREATE INDEX
IF NOT EXISTS
logs_created_at
ON logs (created_at);
`
)
View Source
const (
	// CreatePostgresTable represents a query to create the Postgres logs table.
	CreatePostgresTable = `` /* 251-byte string literal not displayed */

	// CreateSqliteTable represents a query to create the Sqlite logs table.
	CreateSqliteTable = `` /* 267-byte string literal not displayed */

)

Variables

This section is empty.

Functions

This section is empty.

Types

type CleanupResult added in v0.27.0

type CleanupResult struct {
	DeletedCount       int64
	AffectedPartitions []string
}

CleanupResult represents the result of a log cleanup operation.

type Engine added in v0.27.0

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

Engine represents the log functionality that implements the LogInterface interface.

func New

func New(opts ...EngineOpt) (*Engine, error)

New creates and returns a Vela service for integrating with logs in the database.

func (*Engine) CleanLogs added in v0.27.0

func (e *Engine) CleanLogs(ctx context.Context, before int64, batchSize int, withVacuum bool, driver string) (*CleanupResult, error)

CleanLogs deletes log records created before the specified timestamp in batches. This function processes deletions in configurable batches with sleep intervals to reduce database load and prevent timeouts on large datasets. It uses a database-based lock to prevent multiple concurrent cleanup operations. If partitioned mode is enabled and the database is PostgreSQL, it will use partition-aware cleanup for better performance.

func (*Engine) CountLogs added in v0.27.0

func (e *Engine) CountLogs(ctx context.Context) (int64, error)

CountLogs gets the count of all logs from the database.

func (*Engine) CountLogsForBuild added in v0.27.0

func (e *Engine) CountLogsForBuild(ctx context.Context, b *api.Build) (int64, error)

CountLogsForBuild gets the count of logs by build ID from the database.

func (*Engine) CreateLog added in v0.27.0

func (e *Engine) CreateLog(ctx context.Context, l *api.Log) error

CreateLog creates a new log in the database.

func (*Engine) CreateLogIndexes added in v0.27.0

func (e *Engine) CreateLogIndexes(ctx context.Context) error

CreateLogIndexes creates the indexes for the logs table in the database.

func (*Engine) CreateLogTable added in v0.27.0

func (e *Engine) CreateLogTable(ctx context.Context, driver string) error

CreateLogTable creates the logs table in the database.

func (*Engine) DeleteLog added in v0.27.0

func (e *Engine) DeleteLog(ctx context.Context, l *api.Log) error

DeleteLog deletes an existing log from the database.

func (*Engine) GetLog added in v0.27.0

func (e *Engine) GetLog(ctx context.Context, id int64) (*api.Log, error)

GetLog gets a log by ID from the database.

func (*Engine) GetLogForService added in v0.27.0

func (e *Engine) GetLogForService(ctx context.Context, s *api.Service) (*api.Log, error)

GetLogForService gets a log by service ID from the database.

func (*Engine) GetLogForStep added in v0.27.0

func (e *Engine) GetLogForStep(ctx context.Context, s *api.Step) (*api.Log, error)

GetLogForStep gets a log by step ID from the database.

func (*Engine) ListLogs added in v0.27.0

func (e *Engine) ListLogs(ctx context.Context) ([]*api.Log, error)

ListLogs gets a list of all logs from the database.

func (*Engine) ListLogsForBuild added in v0.27.0

func (e *Engine) ListLogsForBuild(ctx context.Context, b *api.Build, page, perPage int) ([]*api.Log, error)

ListLogsForBuild gets a list of logs by build ID from the database.

func (*Engine) UpdateLog added in v0.27.0

func (e *Engine) UpdateLog(ctx context.Context, l *api.Log) error

UpdateLog updates an existing log in the database.

type EngineOpt

type EngineOpt func(*Engine) error

EngineOpt represents a configuration option to initialize the database engine for Logs.

func WithClient

func WithClient(client *gorm.DB) EngineOpt

WithClient sets the gorm.io/gorm client in the database engine for Logs.

func WithCompressionLevel

func WithCompressionLevel(level int) EngineOpt

WithCompressionLevel sets the compression level in the database engine for Logs.

func WithContext added in v0.21.0

func WithContext(ctx context.Context) EngineOpt

WithContext sets the context in the database engine for Logs.

func WithLogPartitionPattern added in v0.27.0

func WithLogPartitionPattern(pattern string) EngineOpt

WithLogPartitionPattern sets the log partition pattern in the log engine.

func WithLogPartitionSchema added in v0.27.0

func WithLogPartitionSchema(schema string) EngineOpt

WithLogPartitionSchema sets the log partition schema in the log engine.

func WithLogPartitioned added in v0.27.0

func WithLogPartitioned(partitioned bool) EngineOpt

WithLogPartitioned sets the log partitioned flag in the log engine.

func WithLogger

func WithLogger(logger *logrus.Entry) EngineOpt

WithLogger sets the github.com/sirupsen/logrus logger in the database engine for Logs.

func WithSkipCreation

func WithSkipCreation(skipCreation bool) EngineOpt

WithSkipCreation sets the skip creation logic in the database engine for Logs.

type LogInterface added in v0.20.0

type LogInterface interface {

	// CreateLogIndexes defines a function that creates the indexes for the logs table.
	CreateLogIndexes(context.Context) error
	// CreateLogTable defines a function that creates the logs table.
	CreateLogTable(context.Context, string) error

	// CountLogs defines a function that gets the count of all logs.
	CountLogs(context.Context) (int64, error)
	// CountLogsForBuild defines a function that gets the count of logs by build ID.
	CountLogsForBuild(context.Context, *api.Build) (int64, error)
	// CreateLog defines a function that creates a new log.
	CreateLog(context.Context, *api.Log) error
	// DeleteLog defines a function that deletes an existing log.
	DeleteLog(context.Context, *api.Log) error
	// GetLog defines a function that gets a log by ID.
	GetLog(context.Context, int64) (*api.Log, error)
	// GetLogForService defines a function that gets a log by service ID.
	GetLogForService(context.Context, *api.Service) (*api.Log, error)
	// GetLogForStep defines a function that gets a log by step ID.
	GetLogForStep(context.Context, *api.Step) (*api.Log, error)
	// ListLogs defines a function that gets a list of all logs.
	ListLogs(context.Context) ([]*api.Log, error)
	// ListLogsForBuild defines a function that gets a list of logs by build ID.
	ListLogsForBuild(context.Context, *api.Build, int, int) ([]*api.Log, error)
	// UpdateLog defines a function that updates an existing log.
	UpdateLog(context.Context, *api.Log) error
	// CleanLogs defines a function that deletes logs older than a specified timestamp in batches.
	CleanLogs(context.Context, int64, int, bool, string) (*CleanupResult, error)
}

Jump to

Keyboard shortcuts

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