log

package module
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

log is a simple user-friendly logger. The intent is clean in-the-terminal experience and readability.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(msg string, pairs ...any)

Log an debug-level message, with optional variadic key-value pairs.

func Debugf

func Debugf(msg string, values ...any)

Log a printf debug-level message.

func Error

func Error(msg string, pairs ...any)

Log an error-level message, with optional variadic key-value pairs.

func Errorf

func Errorf(msg string, values ...any)

Log a printf error-level message.

func Fatal

func Fatal(msg string, pairs ...any)

Log an fatal-level message, with optional variadic key-value pairs, followed by a call to 'os.Exit(1)'.

func Fatalf

func Fatalf(msg string, values ...any)

Log a printf fatal-level message, followed by a call to 'os.Exit(1)'.

func Info

func Info(msg string, pairs ...any)

Log an info-level message, with optional variadic key-value pairs.

func Infof

func Infof(msg string, values ...any)

Log a printf info-level message.

func Panic

func Panic(msg string, pairs ...any)

Panic with the provided message and optional variadic key-value pairs.

func Panicf

func Panicf(msg string, values ...any)

Panic with the provided printf message.

func Warn

func Warn(msg string, pairs ...any)

Log an warn-level message, with optional variadic key-value pairs.

func Warnf

func Warnf(msg string, values ...any)

Log a printf warn-level message.

Types

type Level

type Level uint8
const (
	LevelDebug Level = iota
	LevelInfo
	LevelWarn
	LevelError
	LevelFatal
)

func (Level) String

func (l Level) String() string

type Logger

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

func New

func New(w io.Writer) *Logger

func (*Logger) Debug

func (self *Logger) Debug(msg string, pairs ...any)

Log an debug-level message, with optional variadic key-value pairs.

func (*Logger) Debugf

func (self *Logger) Debugf(msg string, values ...any)

Log a printf debug-level message.

func (*Logger) Error

func (self *Logger) Error(msg string, pairs ...any)

Log an error-level message, with optional variadic key-value pairs.

func (*Logger) Errorf

func (self *Logger) Errorf(msg string, values ...any)

Log a printf error-level message.

func (*Logger) Fatal

func (self *Logger) Fatal(msg string, pairs ...any)

Log an fatal-level message, with optional variadic key-value pairs, followed by a call to 'os.Exit(1)'.

func (*Logger) Fatalf

func (self *Logger) Fatalf(msg string, values ...any)

Log a printf fatal-level message, followed by a call to 'os.Exit(1)'.

func (*Logger) Info

func (self *Logger) Info(msg string, pairs ...any)

Log an info-level message, with optional variadic key-value pairs.

func (*Logger) Infof

func (self *Logger) Infof(msg string, values ...any)

Log a printf info-level message.

func (*Logger) Panic

func (self *Logger) Panic(msg string, pairs ...any)

Panic with the provided message and optional variadic key-value pairs.

func (*Logger) Panicf

func (self *Logger) Panicf(msg string, values ...any)

Panic with the provided printf message.

func (*Logger) SetLevel

func (self *Logger) SetLevel(l Level) *Logger

func (*Logger) SetOptions

func (self *Logger) SetOptions(o Options) *Logger

func (*Logger) SetOutput

func (self *Logger) SetOutput(w io.Writer) *Logger

func (*Logger) Warn

func (self *Logger) Warn(msg string, pairs ...any)

Log an warn-level message, with optional variadic key-value pairs.

func (*Logger) Warnf

func (self *Logger) Warnf(msg string, values ...any)

Log a printf warn-level message.

func (*Logger) With

func (self *Logger) With(pairs ...any) *Logger

func (*Logger) Write

func (self *Logger) Write(b []byte) (int, error)

type Options

type Options uint8
const (
	OptWithLevel Options = 1 << iota
	OptWithCaller
)

func (*Options) SetWithCaller

func (o *Options) SetWithCaller()

func (*Options) SetWithLevel

func (o *Options) SetWithLevel()

func (*Options) UnsetWithCaller

func (o *Options) UnsetWithCaller()

func (*Options) UnsetWithLevel

func (o *Options) UnsetWithLevel()

func (Options) WithCaller

func (o Options) WithCaller() bool

func (Options) WithLevel

func (o Options) WithLevel() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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