log

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2026 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultFileFlags = os.O_CREATE | os.O_APPEND | os.O_WRONLY

	DefaultFileMode os.FileMode = 0o600
	DefaultDirMode  os.FileMode = 0o700
)
View Source
var NopLogger = nopLogger{} //nolint:gochecknoglobals // nop implementation

NopLogger is a logger that does nothing.

Functions

This section is empty.

Types

type Config

type Config struct {
	File   *os.File
	Level  Level
	Format Format
}

Config is a configuration for the loggers.

func DefaultConfig

func DefaultConfig() *Config

type Format added in v1.5.0

type Format int
const (
	TextFormat Format = 1 + iota
	JSONFormat
)

Formats start from 1 to avoid zero value in help printer.

func (Format) String added in v1.5.0

func (m Format) String() string

type Level

type Level int
const (
	ErrorLevel Level = 1 + iota
	WarnLevel
	InfoLevel
	DebugLevel
)

Levels start from 1 to avoid zero value in help printer.

func (Level) String

func (l Level) String() string

type Logger

type Logger interface {
	Errorf(format string, args ...any)
	Infof(format string, args ...any)
	Debugf(format string, args ...any)
}

Logger is the logger used by the forwarder package.

type RotatableFile added in v1.3.2

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

func NewRotatableFile added in v1.3.2

func NewRotatableFile(f *os.File) *RotatableFile

func (*RotatableFile) Close added in v1.3.2

func (w *RotatableFile) Close() error

func (*RotatableFile) Reopen added in v1.3.2

func (w *RotatableFile) Reopen() error

func (*RotatableFile) Write added in v1.3.2

func (w *RotatableFile) Write(p []byte) (n int, err error)

type StructuredLogger added in v1.5.0

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

	ErrorContext(ctx context.Context, msg string, args ...any)
	WarnContext(ctx context.Context, msg string, args ...any)
	InfoContext(ctx context.Context, msg string, args ...any)
	DebugContext(ctx context.Context, msg string, args ...any)

	With(args ...any) StructuredLogger
}

StructuredLogger is the preferred logging interface.

type StructuredLoggerAdapter added in v1.5.0

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

func NewStructuredLoggerAdapter added in v1.5.0

func NewStructuredLoggerAdapter(log Logger) *StructuredLoggerAdapter

func (*StructuredLoggerAdapter) Debug added in v1.5.0

func (l *StructuredLoggerAdapter) Debug(msg string, args ...any)

func (*StructuredLoggerAdapter) DebugContext added in v1.5.0

func (l *StructuredLoggerAdapter) DebugContext(_ context.Context, msg string, args ...any)

func (*StructuredLoggerAdapter) Error added in v1.5.0

func (l *StructuredLoggerAdapter) Error(msg string, args ...any)

func (*StructuredLoggerAdapter) ErrorContext added in v1.5.0

func (l *StructuredLoggerAdapter) ErrorContext(_ context.Context, msg string, args ...any)

func (*StructuredLoggerAdapter) Info added in v1.5.0

func (l *StructuredLoggerAdapter) Info(msg string, args ...any)

func (*StructuredLoggerAdapter) InfoContext added in v1.5.0

func (l *StructuredLoggerAdapter) InfoContext(_ context.Context, msg string, args ...any)

func (*StructuredLoggerAdapter) Warn added in v1.5.0

func (l *StructuredLoggerAdapter) Warn(msg string, args ...any)

func (*StructuredLoggerAdapter) WarnContext added in v1.5.0

func (l *StructuredLoggerAdapter) WarnContext(_ context.Context, msg string, args ...any)

func (*StructuredLoggerAdapter) With added in v1.5.0

func (l *StructuredLoggerAdapter) With(args ...any) StructuredLogger

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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