logger

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: AGPL-3.0 Imports: 5 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(format string, args ...interface{})

Global helper functions

func Error

func Error(format string, args ...interface{})

func Fatal

func Fatal(format string, args ...interface{})

func Info

func Info(format string, args ...interface{})

func SetOutput

func SetOutput(output *os.File)

SetOutput sets the output destination for the default logger

func Warn

func Warn(format string, args ...interface{})

Types

type LogLevel

type LogLevel int
const (
	DEBUG LogLevel = iota
	INFO
	WARN
	ERROR
	FATAL
)

func (LogLevel) String

func (l LogLevel) String() string

String returns the string representation of the log level

type LogWriter

type LogWriter interface {
	// Write writes a log message with the given level, timestamp, and formatted message
	Write(level LogLevel, timestamp time.Time, message string)
}

LogWriter is an interface for writing log messages Implement this interface to create custom log backends (OS log, syslog, etc.)

type Logger

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

Logger struct holds the logger instance

func GetLogger

func GetLogger() *Logger

GetLogger returns the default logger instance

func Init

func Init(logger *Logger) *Logger

Init initializes the default logger

func NewLogger

func NewLogger() *Logger

NewLogger creates a new logger instance with the default StandardWriter

func NewLoggerWithWriter

func NewLoggerWithWriter(writer LogWriter) *Logger

NewLoggerWithWriter creates a new logger instance with a custom LogWriter

func (*Logger) Debug

func (l *Logger) Debug(format string, args ...interface{})

Debug logs debug level messages

func (*Logger) Error

func (l *Logger) Error(format string, args ...interface{})

Error logs error level messages

func (*Logger) Fatal

func (l *Logger) Fatal(format string, args ...interface{})

Fatal logs fatal level messages and exits

func (*Logger) GetWireGuardLogger

func (l *Logger) GetWireGuardLogger(prepend string) *WireGuardLogger

GetWireGuardLogger returns a WireGuard-compatible logger that writes to the newt logger The prepend string is added as a prefix to all log messages

func (*Logger) Info

func (l *Logger) Info(format string, args ...interface{})

Info logs info level messages

func (*Logger) SetLevel

func (l *Logger) SetLevel(level LogLevel)

SetLevel sets the minimum logging level

func (*Logger) SetOutput

func (l *Logger) SetOutput(output *os.File)

SetOutput sets the output destination for the logger (only works with StandardWriter)

func (*Logger) Warn

func (l *Logger) Warn(format string, args ...interface{})

Warn logs warning level messages

type StandardWriter

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

StandardWriter is the default log writer that writes to an io.Writer

func NewStandardWriter

func NewStandardWriter() *StandardWriter

NewStandardWriter creates a new standard writer with the default configuration

func (*StandardWriter) SetOutput

func (w *StandardWriter) SetOutput(output *os.File)

SetOutput sets the output destination

func (*StandardWriter) Write

func (w *StandardWriter) Write(level LogLevel, timestamp time.Time, message string)

Write implements the LogWriter interface

type WireGuardLogger

type WireGuardLogger struct {
	Verbosef func(format string, args ...any)
	Errorf   func(format string, args ...any)
}

WireGuardLogger is a wrapper type that matches WireGuard's Logger interface

Jump to

Keyboard shortcuts

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