logger

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2025 License: Apache-2.0 Imports: 7 Imported by: 3

Documentation

Index

Constants

View Source
const (
	TraceLevel = LogLevel(-8)
	DebugLevel = LogLevel(-4)
	InfoLevel  = LogLevel(0)
	WarnLevel  = LogLevel(4)
	ErrorLevel = LogLevel(8)
	FatalLevel = LogLevel(12)
	PanicLevel = LogLevel(16)
)

Variables

This section is empty.

Functions

func Logf

func Logf(ll LogLevel, format string, args ...interface{})

Logf formats log messages, uses global logger

Deprecated. Use l.Trace(), l.Debug(), l.Info(), l.Warn(), l.Error(), l.Fatal(), l.Panic() instead

func Logln

func Logln(ll LogLevel, format string, args ...interface{})

Logln formats log messages and adds a newline separator.

Deprecated. Use l.Trace(), l.Debug(), l.Info(), l.Warn(), l.Error(), l.Fatal(), l.Panic() instead

func SetDefaultOptions added in v0.1.6

func SetDefaultOptions(
	output io.Writer,
	level LogLevel,
	reportCaller bool,
)

SetDefaultOptions sets global logger's options

Deprecated.

Types

type LogLevel

type LogLevel = slog.Level

LogLevel represents the severity of a log message

type Logger added in v0.1.6

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

Logger wraps slog.Logger with additional functionality

func GetLogger added in v0.1.6

func GetLogger() *Logger

GetLogger returns the global logger instance

func NewLogger added in v0.1.6

func NewLogger(opts Options) *Logger

NewLogger creates a new Logger instance

func (*Logger) Debug added in v0.1.6

func (l *Logger) Debug(ctx context.Context, msg string, args ...interface{})

func (*Logger) Debugf added in v0.1.6

func (l *Logger) Debugf(ctx context.Context, msg string, args ...interface{})

func (*Logger) Error added in v0.1.6

func (l *Logger) Error(ctx context.Context, msg string, args ...interface{})

func (*Logger) Errorf added in v0.1.6

func (l *Logger) Errorf(ctx context.Context, msg string, args ...interface{})

func (*Logger) Fatal added in v0.1.6

func (l *Logger) Fatal(ctx context.Context, msg string, args ...interface{})

func (*Logger) Fatalf added in v0.1.6

func (l *Logger) Fatalf(ctx context.Context, msg string, args ...interface{})

func (*Logger) Info added in v0.1.6

func (l *Logger) Info(ctx context.Context, msg string, args ...interface{})

func (*Logger) Infof added in v0.1.6

func (l *Logger) Infof(ctx context.Context, msg string, args ...interface{})

func (*Logger) Panic added in v0.1.6

func (l *Logger) Panic(ctx context.Context, msg string, args ...interface{})

func (*Logger) Panicf added in v0.1.6

func (l *Logger) Panicf(ctx context.Context, msg string, args ...interface{})

func (*Logger) SetLevel added in v0.1.6

func (l *Logger) SetLevel(level LogLevel)

func (*Logger) SetOptions added in v0.1.6

func (l *Logger) SetOptions(
	output io.Writer,
	level LogLevel,
	reportCaller bool,
	jsonFormat bool,
)

SetOptions sets new options for Logger

func (*Logger) Trace added in v0.1.6

func (l *Logger) Trace(ctx context.Context, msg string, args ...interface{})

func (*Logger) Tracef added in v0.1.6

func (l *Logger) Tracef(ctx context.Context, msg string, args ...interface{})

func (*Logger) Warn added in v0.1.6

func (l *Logger) Warn(ctx context.Context, msg string, args ...interface{})

func (*Logger) Warnf added in v0.1.6

func (l *Logger) Warnf(ctx context.Context, msg string, args ...interface{})

func (*Logger) With added in v0.1.6

func (l *Logger) With(fields map[string]interface{}) *Logger

With returns a new Logger with the given fields added to its context Allows for `nested` logger creation

type Options added in v0.1.6

type Options struct {
	Output        io.Writer
	Level         LogLevel
	ReportCaller  bool
	JSONFormat    bool
	InitialFields map[string]interface{}
}

Options for configuring the logger

Jump to

Keyboard shortcuts

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