log

package
v0.0.0-...-956700b Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(t Tag, msg string, v ...any)

Debug level message.

func Error

func Error(t Tag, msg string, v ...any)

Error level message.

func Fatal

func Fatal(t Tag, msg string, v ...any)

Fatal level message, followed by an exit.

func Info

func Info(t Tag, msg string, v ...any)

Info level message.

func Trace

func Trace(t Tag, msg string, v ...any)

Trace level message.

func Warn

func Warn(t Tag, msg string, v ...any)

Warn level message.

Types

type Level

type Level int
const LevelDebug Level = -4
const LevelError Level = 8
const LevelFatal Level = 12
const LevelInfo Level = 0
const LevelTrace Level = -8
const LevelWarn Level = 4

func ParseLevel

func ParseLevel(s string) (Level, error)

Parses a string representation of a log level (TRACE, DEBUG, INFO, WARN, ERROR, FATAL) into a Level value, returning an error for invalid inputs.

func (Level) String

func (level Level) String() string

Returns the human-readable string representation (e.g., "DEBUG", "INFO") of a logging level, or "UNKNOWN" for invalid values.

type Logger

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

func Default

func Default() *Logger

Default returns the default logger.

func NewJson

func NewJson(w io.Writer) *Logger

Constructs a Logger that writes JSON-formatted logs to the provided io.Writer, with the underlying handler configured for Trace-level logging and custom attribute replacement, while the Logger's active level is set to Info.

func NewText

func NewText(w io.Writer) *Logger

Constructs a Logger that writes text-formatted log entries to the specified io.Writer, configured for trace-level logging with custom attribute handling.

func (*Logger) Debug

func (l *Logger) Debug(t Tag, msg string, v ...any)

Debug level message.

func (*Logger) Error

func (l *Logger) Error(t Tag, msg string, v ...any)

Error level message.

func (*Logger) Fatal

func (l *Logger) Fatal(t Tag, msg string, v ...any)

Fatal level message, followed by an exit.

func (*Logger) Info

func (l *Logger) Info(t Tag, msg string, v ...any)

Info level message.

func (*Logger) Level

func (l *Logger) Level() Level

Level returns the current logging level.

func (*Logger) SetLevel

func (l *Logger) SetLevel(level Level) (prev Level)

SetLevel sets the logging level and returns the previous level.

func (*Logger) Trace

func (l *Logger) Trace(t Tag, msg string, v ...any)

Trace level message.

func (*Logger) Warn

func (l *Logger) Warn(t Tag, msg string, v ...any)

Warn level message.

type Tag

type Tag interface {
	String() string
}

Jump to

Keyboard shortcuts

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