logger

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2025 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(args ...any)

Package-level convenience functions that use the default logger

func Debugf

func Debugf(format string, args ...any)

func Error

func Error(args ...any)

func Errorf

func Errorf(format string, args ...any)

func Fatal

func Fatal(args ...any)

func Fatalf

func Fatalf(format string, args ...any)

func Info

func Info(args ...any)

func Infof

func Infof(format string, args ...any)

func Panic

func Panic(args ...any)

func Panicf

func Panicf(format string, args ...any)

func SetLevel

func SetLevel(level LogLevel)

func SetLogger

func SetLogger(logger Logger)

SetLogger allows users to replace the default logger with their own implementation

func SetOutput

func SetOutput(output io.Writer)

func Warn

func Warn(args ...any)

func Warnf

func Warnf(format string, args ...any)

Types

type DefaultLogger

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

DefaultLogger is a simple implementation of the Logger interface

func NewDefaultLogger

func NewDefaultLogger() *DefaultLogger

NewDefaultLogger creates a new instance of DefaultLogger

func (*DefaultLogger) Debug

func (l *DefaultLogger) Debug(args ...any)

Debug logs a debug message

func (*DefaultLogger) Debugf

func (l *DefaultLogger) Debugf(format string, args ...any)

Debugf logs a formatted debug message

func (*DefaultLogger) Error

func (l *DefaultLogger) Error(args ...any)

Error logs an error message

func (*DefaultLogger) Errorf

func (l *DefaultLogger) Errorf(format string, args ...any)

Errorf logs a formatted error message

func (*DefaultLogger) Fatal

func (l *DefaultLogger) Fatal(args ...any)

Fatal logs a fatal message and exits the program

func (*DefaultLogger) Fatalf

func (l *DefaultLogger) Fatalf(format string, args ...any)

Fatalf logs a formatted fatal message and exits the program

func (*DefaultLogger) GetLevel

func (l *DefaultLogger) GetLevel() LogLevel

GetLevel returns the current logging level

func (*DefaultLogger) Info

func (l *DefaultLogger) Info(args ...any)

Info logs an info message

func (*DefaultLogger) Infof

func (l *DefaultLogger) Infof(format string, args ...any)

Infof logs a formatted info message

func (*DefaultLogger) Panic

func (l *DefaultLogger) Panic(args ...any)

Panic logs a panic message and panics

func (*DefaultLogger) Panicf

func (l *DefaultLogger) Panicf(format string, args ...any)

Panicf logs a formatted panic message and panics

func (*DefaultLogger) SetLevel

func (l *DefaultLogger) SetLevel(level LogLevel)

SetLevel sets the logging level

func (*DefaultLogger) SetOutput

func (l *DefaultLogger) SetOutput(output io.Writer)

SetOutput sets the output destination for the logger

func (*DefaultLogger) Warn

func (l *DefaultLogger) Warn(args ...any)

Warn logs a warning message

func (*DefaultLogger) Warnf

func (l *DefaultLogger) Warnf(format string, args ...any)

Warnf logs a formatted warning message

type LogLevel

type LogLevel int

LogLevel represents the severity level of a log entry.

const (
	// PanicLevel level, highest level of severity.
	PanicLevel LogLevel = iota
	// FatalLevel level, logs and then calls os.Exit(1).
	FatalLevel
	// ErrorLevel level, used for errors that should definitely be noted.
	ErrorLevel
	// WarnLevel level, used for non-critical entries that deserve attention.
	WarnLevel
	// InfoLevel level, general operational entries about what's going on.
	InfoLevel
	// DebugLevel level, very verbose logging.
	DebugLevel
	// TraceLevel level, denotes finer-grained informational events than the Debug.
	TraceLevel
)

func GetLevel

func GetLevel() LogLevel

func (LogLevel) String

func (l LogLevel) String() string

String returns the string representation of the LogLevel.

type Logger

type Logger interface {
	// Standard logging methods
	Debug(args ...any)
	Debugf(format string, args ...any)
	Info(args ...any)
	Infof(format string, args ...any)
	Warn(args ...any)
	Warnf(format string, args ...any)
	Error(args ...any)
	Errorf(format string, args ...any)
	Fatal(args ...any)
	Fatalf(format string, args ...any)
	Panic(args ...any)
	Panicf(format string, args ...any)

	// Level management
	SetLevel(level LogLevel)
	GetLevel() LogLevel

	// Output management
	SetOutput(output io.Writer)
}

Logger defines the interface for logging. This interface is compatible with logrus and other popular Go loggers

func GetLogger

func GetLogger() Logger

GetLogger returns the current logger instance

type StdLoggerWrapper

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

StdLoggerWrapper wraps the standard library log.Logger to implement our Logger interface This allows users to use stdlib log.Logger with APIRight

func NewStdLoggerWrapper

func NewStdLoggerWrapper(stdLogger *log.Logger) *StdLoggerWrapper

NewStdLoggerWrapper creates a new wrapper around a standard library logger

func WrapStdLogger

func WrapStdLogger() *StdLoggerWrapper

WrapStdLogger wraps the default standard library logger

func (*StdLoggerWrapper) Debug

func (w *StdLoggerWrapper) Debug(args ...any)

func (*StdLoggerWrapper) Debugf

func (w *StdLoggerWrapper) Debugf(format string, args ...any)

func (*StdLoggerWrapper) Error

func (w *StdLoggerWrapper) Error(args ...any)

func (*StdLoggerWrapper) Errorf

func (w *StdLoggerWrapper) Errorf(format string, args ...any)

func (*StdLoggerWrapper) Fatal

func (w *StdLoggerWrapper) Fatal(args ...any)

func (*StdLoggerWrapper) Fatalf

func (w *StdLoggerWrapper) Fatalf(format string, args ...any)

func (*StdLoggerWrapper) GetLevel

func (w *StdLoggerWrapper) GetLevel() LogLevel

func (*StdLoggerWrapper) Info

func (w *StdLoggerWrapper) Info(args ...any)

func (*StdLoggerWrapper) Infof

func (w *StdLoggerWrapper) Infof(format string, args ...any)

func (*StdLoggerWrapper) Panic

func (w *StdLoggerWrapper) Panic(args ...any)

func (*StdLoggerWrapper) Panicf

func (w *StdLoggerWrapper) Panicf(format string, args ...any)

func (*StdLoggerWrapper) SetLevel

func (w *StdLoggerWrapper) SetLevel(level LogLevel)

func (*StdLoggerWrapper) SetOutput

func (w *StdLoggerWrapper) SetOutput(output io.Writer)

func (*StdLoggerWrapper) Warn

func (w *StdLoggerWrapper) Warn(args ...any)

func (*StdLoggerWrapper) Warnf

func (w *StdLoggerWrapper) Warnf(format string, args ...any)

Jump to

Keyboard shortcuts

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