logging

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseMetadataWriter added in v1.1.0

func CloseMetadataWriter(w io.Writer) error

CloseMetadataWriter flushes the metadata table.

func GetMetadataWriter added in v1.1.0

func GetMetadataWriter(toLog bool) io.Writer

GetMetadataWriter returns a writer for the metadata table.

func NewDefaultLogger

func NewDefaultLogger() *slog.Logger

NewDefaultLogger returns default logger.

func NewLogger

func NewLogger(cfg *Config) (*slog.Logger, func() error, error)

NewLogger creates a new logger with the given configuration. Returns logger, close function, and error.

func PrintBackupDetailsByRoutine added in v1.1.0

func PrintBackupDetailsByRoutine(
	data map[string][]api.DtoBackupDetails, isIncremental, toLog bool, logger *slog.Logger,
)

PrintBackupDetailsByRoutine prints a per-routine grouped listing of backup details. When toLog is true the entire map is logged via slog; otherwise a table grouped by routine is rendered to stderr.

func PrintBackupDetailsForRoutine added in v1.1.0

func PrintBackupDetailsForRoutine(
	data []api.DtoBackupDetails, name string, isIncremental, toLog bool, logger *slog.Logger,
)

PrintBackupDetailsForRoutine prints a flat listing of backup details for a single routine. When toLog is true the slice is logged via slog; otherwise a table is rendered to stderr.

func PrintBackupState added in v1.1.0

func PrintBackupState(state *api.DtoRoutineState, name string, toLog bool, logger *slog.Logger)

PrintBackupState prints the backup routine state for the given routine. When toLog is true the data is emitted as a structured log entry through the provided logger; otherwise it is rendered as a human-readable section to stderr.

func PrintCluster added in v1.1.0

func PrintCluster(name string, cluster *api.DtoAerospikeCluster, toLog bool, logger *slog.Logger)

PrintCluster prints a single cluster definition. When toLog is true the DTO is logged via slog; otherwise key fields are rendered as a section.

func PrintClusters added in v1.1.0

func PrintClusters(clusters map[string]api.DtoAerospikeCluster, toLog bool, logger *slog.Logger)

PrintClusters prints all configured clusters keyed by name. When toLog is true the entire map is logged via slog; otherwise a tabular summary is rendered to stderr.

func PrintConfig added in v1.1.0

func PrintConfig(cfg *api.DtoConfig, toLog bool, logger *slog.Logger)

PrintConfig prints the full service configuration. When toLog is true the entire DTO is logged as a structured entry; otherwise each section (clusters, policies, routines, storage) is rendered as its own table.

func PrintMetadata added in v1.1.0

func PrintMetadata(w io.Writer, data models.Metadata, toLog bool, logger *slog.Logger)

PrintMetadata displays the node data in a formatted table.

func PrintPolicies added in v1.1.0

func PrintPolicies(policies map[string]api.DtoBackupPolicy, toLog bool, logger *slog.Logger)

PrintPolicies prints all configured backup policies keyed by name. When toLog is true the entire map is logged via slog; otherwise a tabular summary is rendered to stderr.

func PrintPolicy added in v1.1.0

func PrintPolicy(name string, policy *api.DtoBackupPolicy, toLog bool, logger *slog.Logger)

PrintPolicy prints a single backup policy. When toLog is true the DTO is logged via slog; otherwise key fields are rendered as a section.

func PrintRestoreJobs added in v1.1.0

func PrintRestoreJobs(jobs map[string]api.DtoRestoreJobStatus, toLog bool, logger *slog.Logger)

PrintRestoreJobs prints a listing of restore jobs keyed by job ID. When toLog is true the data is emitted as a structured log entry; otherwise a table is rendered to stderr.

func PrintRestoreStatus added in v1.1.0

func PrintRestoreStatus(status *api.DtoRestoreJobStatus, jobID int64, toLog bool, logger *slog.Logger)

PrintRestoreStatus prints a single restore job status. When toLog is true the data is emitted as a structured log entry; otherwise it is rendered as a human-readable section to stderr.

func PrintRoutine added in v1.1.0

func PrintRoutine(name string, routine *api.DtoBackupRoutine, toLog bool, logger *slog.Logger)

PrintRoutine prints a single backup routine. When toLog is true the DTO is logged via slog; otherwise key fields are rendered as a section.

func PrintRoutines added in v1.1.0

func PrintRoutines(routines map[string]api.DtoBackupRoutine, toLog bool, logger *slog.Logger)

PrintRoutines prints all configured backup routines keyed by name. When toLog is true the entire map is logged via slog; otherwise a tabular summary is rendered to stderr.

func PrintStorage added in v1.1.0

func PrintStorage(name string, storage *api.DtoStorage, toLog bool, logger *slog.Logger)

PrintStorage prints a single storage definition. When toLog is true the DTO is logged via slog; otherwise key fields for the active provider are rendered as a section.

func PrintStorageList added in v1.1.0

func PrintStorageList(storage map[string]api.DtoStorage, toLog bool, logger *slog.Logger)

PrintStorageList prints all configured storage entries keyed by name. When toLog is true the entire map is logged via slog; otherwise a tabular summary is rendered to stderr.

func ReportBackup

func ReportBackup(stats *bModels.BackupStats, isXdr, toLog bool, logger *slog.Logger)

ReportBackup prints the backup report. if toLog is true, it prints the report to log, but logger must be passed

func ReportEstimate

func ReportEstimate(estimate uint64, toLog bool, logger *slog.Logger)

ReportEstimate prints the estimate report. if toLog is true, it prints the report to log, but logger must be passed estimate is the size of the backup file in bytes.

func ReportRestore

func ReportRestore(stats *bModels.RestoreStats, isValidation, toLog bool, logger *slog.Logger)

ReportRestore prints the restore report. if toLog is true, it prints the report to log, but logger must be passed

func SetOutWriter added in v1.1.0

func SetOutWriter(w io.Writer) io.Writer

SetOutWriter replaces the package-level output writer used by all pretty-printers. It returns the previous writer so callers (typically tests) can restore it. Production code does not call this function.

Types

type CobraLogger

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

CobraLogger is a wrapper around slog to use it as the default writer for cobra output.

func NewCobraLogger

func NewCobraLogger(logger *slog.Logger) *CobraLogger

NewCobraLogger returns a wrapper for logging cobra output.

func (*CobraLogger) Write

func (c *CobraLogger) Write(p []byte) (n int, err error)

Write prints any message with slog.logger on WARN level.

type Config added in v1.1.0

type Config struct {
	// Level is parsed when Verbose==true (keeps your original behavior).
	// Valid: debug, info, warn, error.
	Level   string
	Verbose bool

	// JSON switches handler format for both stderr and file handlers.
	JSON bool

	// File used to write logs to the file.
	File string
}

func NewConfig added in v1.1.0

func NewConfig(verbose, json bool, level, file string) *Config

NewConfig creates a new Config with the given parameters.

func (*Config) Validate added in v1.1.0

func (c *Config) Validate() error

Jump to

Keyboard shortcuts

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