logs

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSlogNoOpLogger

func NewSlogNoOpLogger() *slog.Logger

NewSlogNoOpLogger creates a no-op slog logger for testing.

func NewTeeHandler

func NewTeeHandler(handlers ...slog.Handler) slog.Handler

Types

type Gen3Logger

type Gen3Logger struct {
	*slog.Logger

	FailedMap map[string]common.RetryObject // Maps filePath to FileMetadata
	// contains filtered or unexported fields
}

--- Gen3Logger Implementation ---

func New

func New(profile string, opts ...Option) (*Gen3Logger, func())

func NewGen3Logger

func NewGen3Logger(logger *slog.Logger, logDir, profile string) *Gen3Logger

NewGen3Logger creates a new Gen3Logger wrapping the provided slog.Logger.

func (*Gen3Logger) Debug

func (t *Gen3Logger) Debug(msg string, args ...any)

func (*Gen3Logger) DebugContext

func (t *Gen3Logger) DebugContext(ctx context.Context, msg string, args ...any)

func (*Gen3Logger) DeleteFromFailedLog

func (t *Gen3Logger) DeleteFromFailedLog(path string)

func (*Gen3Logger) Error

func (t *Gen3Logger) Error(msg string, args ...any)

func (*Gen3Logger) ErrorContext

func (t *Gen3Logger) ErrorContext(ctx context.Context, msg string, args ...any)

func (*Gen3Logger) Failed

func (t *Gen3Logger) Failed(filePath, filename string, metadata common.FileMetadata, guid string, retryCount int, multipart bool)

func (*Gen3Logger) FailedContext

func (t *Gen3Logger) FailedContext(ctx context.Context, filePath, filename string, metadata common.FileMetadata, guid string, retryCount int, multipart bool)

func (*Gen3Logger) Fatal

func (t *Gen3Logger) Fatal(v ...any)

func (*Gen3Logger) Fatalf

func (t *Gen3Logger) Fatalf(format string, v ...any)

func (*Gen3Logger) GetFailedLogMap

func (t *Gen3Logger) GetFailedLogMap() map[string]common.RetryObject

func (*Gen3Logger) GetSucceededCount

func (t *Gen3Logger) GetSucceededCount() int

func (*Gen3Logger) GetSucceededLogMap

func (t *Gen3Logger) GetSucceededLogMap() map[string]string

func (*Gen3Logger) Info

func (t *Gen3Logger) Info(msg string, args ...any)

func (*Gen3Logger) InfoContext

func (t *Gen3Logger) InfoContext(ctx context.Context, msg string, args ...any)

func (*Gen3Logger) Printf

func (t *Gen3Logger) Printf(format string, v ...any)

func (*Gen3Logger) Println

func (t *Gen3Logger) Println(v ...any)

func (*Gen3Logger) Scoreboard

func (t *Gen3Logger) Scoreboard() *Scoreboard

Scoreboard returns the embedded Scoreboard.

func (*Gen3Logger) Succeeded

func (t *Gen3Logger) Succeeded(filePath, guid string)

func (*Gen3Logger) SucceededContext

func (t *Gen3Logger) SucceededContext(ctx context.Context, filePath, guid string)

func (*Gen3Logger) Warn

func (t *Gen3Logger) Warn(msg string, args ...any)

func (*Gen3Logger) WarnContext

func (t *Gen3Logger) WarnContext(ctx context.Context, msg string, args ...any)

func (*Gen3Logger) Writer

func (t *Gen3Logger) Writer() io.Writer

Writer returns os.Stderr for legacy compatibility (used by Scoreboard's tabwriter).

type Option

type Option func(*config)

func WithBaseLogger

func WithBaseLogger(base *slog.Logger) Option

func WithConsole

func WithConsole() Option

func WithFailedLog

func WithFailedLog() Option

func WithMessageFile

func WithMessageFile() Option

func WithNoConsole

func WithNoConsole() Option

func WithNoMessageFile

func WithNoMessageFile() Option

func WithScoreboard

func WithScoreboard() Option

func WithSucceededLog

func WithSucceededLog() Option

type ProgressHandler

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

ProgressHandler is a slog.Handler that captures log messages and forwards them to a ProgressCallback if one is present in the context.

func NewProgressHandler

func NewProgressHandler(next slog.Handler) *ProgressHandler

func (*ProgressHandler) Enabled

func (h *ProgressHandler) Enabled(ctx context.Context, level slog.Level) bool

func (*ProgressHandler) Handle

func (h *ProgressHandler) Handle(ctx context.Context, r slog.Record) error

func (*ProgressHandler) WithAttrs

func (h *ProgressHandler) WithAttrs(attrs []slog.Attr) slog.Handler

func (*ProgressHandler) WithGroup

func (h *ProgressHandler) WithGroup(name string) slog.Handler

type Scoreboard

type Scoreboard struct {
	Counts []int // index 0 = success on first try, 1 = after 1 retry, ..., last = failed
	// contains filtered or unexported fields
}

Scoreboard holds retry statistics

func NewSB

func NewSB(maxRetryCount int, log *Gen3Logger) *Scoreboard

New creates a new scoreboard maxRetryCount = how many retries you allow before giving up

func (*Scoreboard) IncrementSB

func (s *Scoreboard) IncrementSB(retryCount int)

Increment records a result after `retryCount` attempts retryCount == 0 → succeeded on first try retryCount == max → final failure

func (*Scoreboard) PrintSB

func (s *Scoreboard) PrintSB()

Print the beautiful table at the end

type TeeHandler

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

TeeHandler fans out log records to multiple handlers

func (*TeeHandler) Enabled

func (h *TeeHandler) Enabled(ctx context.Context, level slog.Level) bool

func (*TeeHandler) Handle

func (h *TeeHandler) Handle(ctx context.Context, r slog.Record) error

func (*TeeHandler) WithAttrs

func (h *TeeHandler) WithAttrs(attrs []slog.Attr) slog.Handler

func (*TeeHandler) WithGroup

func (h *TeeHandler) WithGroup(name string) slog.Handler

Jump to

Keyboard shortcuts

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