utils

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAllTargetsOffline = errors.New("all the targets are offline")

Functions

func GetRandomClient

func GetRandomClient(clients []*minio.Client) (*minio.Client, error)

GetRandomClient fetches a random client from the provided list of clients.

func IsContextError

func IsContextError(err error) bool

IsContextError returns true if the error relates to context cancel or deadline exceeded.

Types

type FileLogger

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

FileLogger logs the messages to a file.

func NewLogger

func NewLogger(file *os.File, verbosity int) *FileLogger

New returns the FileLogger instance.

func (*FileLogger) CurrentV

func (l *FileLogger) CurrentV() int

CurrentV returns the current verbosity level configured.

func (*FileLogger) Log

func (l *FileLogger) Log(message string) error

Log writes the message to the file.

func (*FileLogger) V

func (l *FileLogger) V(v int) Logger

V returns the FileLogger if the verbosity level is less than the configured level. Else, returns a no-op logger.

type Logger

type Logger interface {
	Log(message string) error
	V(level int) Logger
	CurrentV() int
}

Logger implements the Log interface.

type NoOpLogger

type NoOpLogger struct{}

NoOpLogger is used for a nil logger.

func (NoOpLogger) CurrentV

func (l NoOpLogger) CurrentV() int

CurrentV for NoOP returns -1 (For interface compatibility).

func (NoOpLogger) Log

func (l NoOpLogger) Log(message string) error

Log does a No-Op.

func (NoOpLogger) V

func (l NoOpLogger) V(v int) Logger

V returns the FileLogger if the verbosity level is less than the configured level. Else, returns a no-op logger.

Jump to

Keyboard shortcuts

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