slog

package
v0.0.0-...-fbf15f4 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 13 Imported by: 9

Documentation

Index

Constants

View Source
const (
	FlagNone  Flags = iota
	FlagUTC         = 0x0001
	FlagNanos       = 0x0002
)
View Source
const (
	TimeLayout        = "2006-01-02T15:04:05-07:00"
	TimeLayoutUTC     = "2006-01-02T15:04:05Z07:00"
	TimeLayoutNano    = "2006-01-02T15:04:05.999999999-07:00"
	TimeLayoutUTCNano = "2006-01-02T15:04:05.999999999Z07:00"
)

TimeLayout is a fixed-length layout conforming to both ISO 8601 and RFC 3339

Variables

This section is empty.

Functions

func AppendMsg

func AppendMsg(b []byte, v ...any) []byte

AppendMsg appends a message to the given byte slice.

func AppendMsgf

func AppendMsgf(b []byte, format string, v ...any) []byte

AppendMsgf appends a formatted message to the given byte slice.

func Binary

func Binary(level Level, bin []byte, v ...any)

Binary logs binary data at the given level.

func Binaryf

func Binaryf(level Level, bin []byte, wrap int, format string, v ...any)

Binaryf logs binary data at the given level.

func Check

func Check(cond bool, v ...any)

Check checks the given condition and logs a fatal message if the condition is false.

func CheckLevel

func CheckLevel(level Level) bool

CheckLevel checks whether the given level is enabled.

func Checkf

func Checkf(cond bool, format string, v ...any)

Checkf checks the given condition and logs a fatal message if the condition is false.

func Debug

func Debug(v ...any)

Debug logs extra information for debugging.

func Debugf

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

Debugf logs extra information for debugging.

func Error

func Error(v ...any)

Error logs issues that shouldn't be ignored.

func Errorf

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

Errorf logs issues that shouldn't be ignored.

func Fatal

func Fatal(v ...any)

Fatal logs serious problems that are likely to cause the program to exit.

func Fatalf

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

Fatalf logs serious problems that are likely to cause the program to exit.

func Info

func Info(v ...any)

Info logs normal work reports.

func Infof

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

Infof logs normal work reports.

func Notice

func Notice(v ...any)

Notice logs important status changes. The prefix is 'I'.

func Noticef

func Noticef(format string, v ...any)

Noticef logs important status changes. The prefix is 'I'.

func Printf

func Printf(calldepth int, level Level, extra func(io.Writer) error, format string, v ...any) error

Printf is the low-level interface to write arbitary log messages.

func Println

func Println(calldepth int, level Level, extra func(io.Writer) error, v ...any) error

Println is the low-level interface to write arbitary log messages.

func Stack

func Stack(level Level, skip int, v ...any)

Stack logs a stack trace at the given level.

func Stackf

func Stackf(level Level, skip int, format string, v ...any)

Stackf logs a stack trace at the given level.

func Temporary

func Temporary(v ...any)

Temporary prints debug message regardless of log level.

func Temporaryf

func Temporaryf(format string, v ...any)

Temporaryf prints debug message regardless of log level.

func Text

func Text(level Level, txt string, v ...any)

Text logs a long text message at the given level.

func Textf

func Textf(level Level, txt string, wrap int, format string, v ...any)

Textf logs a long text message at the given level.

func Verbose

func Verbose(v ...any)

Verbose logs details for inspecting specific issues.

func Verbosef

func Verbosef(format string, v ...any)

Verbosef logs details for inspecting specific issues.

func VeryVerbose

func VeryVerbose(v ...any)

VeryVerbose logs more details that may significantly impact performance. The prefix is 'V'.

func VeryVerbosef

func VeryVerbosef(format string, v ...any)

VeryVerbosef logs more details that may significantly impact performance. The prefix is 'V'.

func Warning

func Warning(v ...any)

Warning logs issues that may be ignored.

func Warningf

func Warningf(format string, v ...any)

Warningf logs issues that may be ignored.

func Wrap

func Wrap(logger *Logger, level Level) *log.Logger

Wrap wraps the given Logger into a standard log.Logger with the specified log level.

Types

type Flags

type Flags int

type Level

type Level int32
const (
	LevelSilence Level = iota
	LevelFatal
	LevelError
	LevelWarning
	LevelNotice
	LevelInfo
	LevelDebug
	LevelVerbose
	LevelVeryVerbose
)

type Logger

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

Logger represents a logger instance.

func Default

func Default() *Logger

Default returns the default logger.

func NewLogger

func NewLogger() *Logger

NewLogger creates and returns a new Logger instance.

func (*Logger) Debug

func (l *Logger) Debug(v ...any)

Debug logs extra information for debugging.

func (*Logger) Debugf

func (l *Logger) Debugf(format string, v ...any)

Debugf logs extra information for debugging.

func (*Logger) Error

func (l *Logger) Error(v ...any)

Error logs issues that shouldn't be ignored.

func (*Logger) Errorf

func (l *Logger) Errorf(format string, v ...any)

Errorf logs issues that shouldn't be ignored.

func (*Logger) Fatal

func (l *Logger) Fatal(v ...any)

Fatal logs serious problems that are likely to cause the program to exit.

func (*Logger) Fatalf

func (l *Logger) Fatalf(format string, v ...any)

Fatalf logs serious problems that are likely to cause the program to exit.

func (*Logger) Info

func (l *Logger) Info(v ...any)

Info logs normal work reports.

func (*Logger) Infof

func (l *Logger) Infof(format string, v ...any)

Infof logs normal work reports.

func (*Logger) Level

func (l *Logger) Level() Level

Level returns the current logging level of the logger.

func (*Logger) Notice

func (l *Logger) Notice(v ...any)

Notice logs important status changes. The prefix is 'I'.

func (*Logger) Noticef

func (l *Logger) Noticef(format string, v ...any)

Noticef logs important status changes. The prefix is 'I'.

func (*Logger) Printf

func (l *Logger) Printf(calldepth int, level Level, extra func(io.Writer) error, format string, v ...any) error

Printf is the low-level interface to write arbitrary log messages.

func (*Logger) Println

func (l *Logger) Println(calldepth int, level Level, extra func(io.Writer) error, v ...any) error

Println is the low-level interface to write arbitary log messages.

func (*Logger) SetFilePrefix

func (l *Logger) SetFilePrefix(prefix string)

SetFilePrefix sets the file prefix to be stripped from file paths in log messages.

func (*Logger) SetFlags

func (l *Logger) SetFlags(flags Flags)

SetFlags sets the flags for the logger.

func (*Logger) SetLevel

func (l *Logger) SetLevel(level Level)

SetLevel sets the logging level for the logger.

func (*Logger) SetOutput

func (l *Logger) SetOutput(t OutputType, v ...any)

SetOutput sets the output type and parameters for the logger.

func (*Logger) Temporary

func (l *Logger) Temporary(v ...any)

Temporary prints debug message regardless of log level.

func (*Logger) Temporaryf

func (l *Logger) Temporaryf(format string, v ...any)

Temporaryf prints debug message regardless of log level.

func (*Logger) Verbose

func (l *Logger) Verbose(v ...any)

Verbose logs details for inspecting specific issues.

func (*Logger) Verbosef

func (l *Logger) Verbosef(format string, v ...any)

Verbosef logs details for inspecting specific issues.

func (*Logger) VeryVerbose

func (l *Logger) VeryVerbose(v ...any)

VeryVerbose logs more details that may significantly impact performance. The prefix is 'V'.

func (*Logger) VeryVerbosef

func (l *Logger) VeryVerbosef(format string, v ...any)

VeryVerbosef logs more details that may significantly impact performance. The prefix is 'V'.

func (*Logger) Warning

func (l *Logger) Warning(v ...any)

Warning logs issues that may be ignored.

func (*Logger) Warningf

func (l *Logger) Warningf(format string, v ...any)

Warningf logs issues that may be ignored.

type OutputType

type OutputType int
const (
	OutputDiscard OutputType = iota
	OutputTerminal
	OutputWriter
	OutputSyslog
)

type WriteFlusher

type WriteFlusher interface {
	io.Writer
	Flush() error
}

func NewWriteFlusher

func NewWriteFlusher(w io.Writer) WriteFlusher

Jump to

Keyboard shortcuts

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