logger

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsoleLogger

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

ConsoleLogger writes log entries to os.Stdout with level filtering.

func NewConsoleLogger

func NewConsoleLogger(level LogLevel) *ConsoleLogger

NewConsoleLogger creates a ConsoleLogger that only emits messages at or above the given level. Output goes to os.Stdout.

func (*ConsoleLogger) Debug

func (c *ConsoleLogger) Debug(msg string, args ...any)

func (*ConsoleLogger) Error

func (c *ConsoleLogger) Error(msg string, args ...any)

func (*ConsoleLogger) Info

func (c *ConsoleLogger) Info(msg string, args ...any)

func (*ConsoleLogger) Warn

func (c *ConsoleLogger) Warn(msg string, args ...any)

type FileLogger

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

FileLogger writes log entries to a file with level filtering.

func NewFileLogger

func NewFileLogger(path string, level LogLevel) (*FileLogger, error)

NewFileLogger creates a FileLogger that appends to the file at path. Only messages at or above the given level are written.

func (*FileLogger) Close

func (fl *FileLogger) Close() error

Close closes the underlying file. It is a no-op if the FileLogger was created with a plain io.Writer (testing path).

func (*FileLogger) Debug

func (fl *FileLogger) Debug(msg string, args ...any)

func (*FileLogger) Error

func (fl *FileLogger) Error(msg string, args ...any)

func (*FileLogger) Info

func (fl *FileLogger) Info(msg string, args ...any)

func (*FileLogger) Warn

func (fl *FileLogger) Warn(msg string, args ...any)

type LogLevel

type LogLevel int

LogLevel represents the severity of a log message.

const (
	// LevelDebug is the most verbose log level.
	LevelDebug LogLevel = iota
	// LevelInfo is the default log level for informational messages.
	LevelInfo
	// LevelWarn indicates a potential issue.
	LevelWarn
	// LevelError indicates a failure.
	LevelError
)

func ParseLevel

func ParseLevel(s string) LogLevel

ParseLevel converts a string to a LogLevel. It is case-insensitive. Unrecognised strings default to LevelInfo.

func (LogLevel) String

func (l LogLevel) String() string

String returns the human-readable name of the log level.

type Logger

type Logger interface {
	Debug(msg string, args ...any)
	Info(msg string, args ...any)
	Warn(msg string, args ...any)
	Error(msg string, args ...any)
}

Logger defines the logging interface used throughout go-migration.

type NopLogger

type NopLogger struct{}

NopLogger is a logger that silently discards all messages.

func (NopLogger) Debug

func (NopLogger) Debug(string, ...any)

func (NopLogger) Error

func (NopLogger) Error(string, ...any)

func (NopLogger) Info

func (NopLogger) Info(string, ...any)

func (NopLogger) Warn

func (NopLogger) Warn(string, ...any)

Jump to

Keyboard shortcuts

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