logging

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Level

type Level int

Level represents log level

const (
	// LevelDebug is for debug messages
	LevelDebug Level = iota
	// LevelInfo is for informational messages
	LevelInfo
	// LevelWarn is for warning messages
	LevelWarn
	// LevelError is for error messages
	LevelError
	// LevelFatal is for fatal error messages
	LevelFatal
)

func ParseLevel

func ParseLevel(s string) Level

ParseLevel parses a string into a Level

func (Level) String

func (l Level) String() string

String returns the string representation of the log level

type Logger

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

Logger is the interface for logging

type SimpleLogger

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

SimpleLogger is a basic logger implementation

func NewSimpleLogger

func NewSimpleLogger(module string, level Level, useColors bool) *SimpleLogger

NewSimpleLogger creates a new SimpleLogger

func (*SimpleLogger) Debug

func (l *SimpleLogger) Debug(msg string, args ...interface{})

Debug logs a debug message

func (*SimpleLogger) Error

func (l *SimpleLogger) Error(msg string, args ...interface{})

Error logs an error message

func (*SimpleLogger) Fatal

func (l *SimpleLogger) Fatal(msg string, args ...interface{})

Fatal logs a fatal error message and exits

func (*SimpleLogger) Info

func (l *SimpleLogger) Info(msg string, args ...interface{})

Info logs an informational message

func (*SimpleLogger) Warn

func (l *SimpleLogger) Warn(msg string, args ...interface{})

Warn logs a warning message

func (*SimpleLogger) WithModule

func (l *SimpleLogger) WithModule(module string) Logger

WithModule creates a new logger with a hierarchical component name. If the current logger already has a component (module), the new component is appended with "/" as a separator (e.g., "proxy/middleware/session"). This allows tracing the origin of log messages through component hierarchy.

type TestLogger

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

TestLogger is a logger for testing that suppresses output

func NewTestLogger

func NewTestLogger() *TestLogger

NewTestLogger creates a new test logger that suppresses output If you need to see logs during tests, use NewTestLoggerVerbose instead

func NewTestLoggerVerbose

func NewTestLoggerVerbose(t *testing.T) *TestLogger

NewTestLoggerVerbose creates a test logger that outputs to testing.T

func (*TestLogger) Debug

func (l *TestLogger) Debug(msg string, args ...interface{})

Debug logs a debug message

func (*TestLogger) Error

func (l *TestLogger) Error(msg string, args ...interface{})

Error logs an error message

func (*TestLogger) Fatal

func (l *TestLogger) Fatal(msg string, args ...interface{})

Fatal logs a fatal error message (but doesn't exit in tests)

func (*TestLogger) Info

func (l *TestLogger) Info(msg string, args ...interface{})

Info logs an informational message

func (*TestLogger) Warn

func (l *TestLogger) Warn(msg string, args ...interface{})

Warn logs a warning message

func (*TestLogger) WithModule

func (l *TestLogger) WithModule(module string) Logger

WithModule creates a new logger with a hierarchical component name. If the current logger already has a component (module), the new component is appended with "/" as a separator (e.g., "proxy/middleware/session").

Jump to

Keyboard shortcuts

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