logger

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ColoredSegment added in v1.1.0

type ColoredSegment struct {
	Text  string
	Color func(a ...interface{}) string
}

ColoredSegment represents a text segment with its color

func ErrorSegment added in v1.1.0

func ErrorSegment(text string) ColoredSegment

func HighlightSegment added in v1.1.0

func HighlightSegment(text string) ColoredSegment

func InfoSegment added in v1.1.0

func InfoSegment(text string) ColoredSegment

type LogLevel added in v1.3.0

type LogLevel int
const (
	QuietLevel LogLevel = iota
	DefaultLevel
	VerboseLevel
)

type Logger

type Logger struct {
	*log.Logger
	// contains filtered or unexported fields
}

Logger wraps the standard logger with custom formatting

func New

func New(opts ...Option) *Logger

New creates a new Logger instance with the given options

func (*Logger) Debug added in v1.3.0

func (l *Logger) Debug(format string, v ...interface{})

Debug logs a debug message (only in verbose mode)

func (*Logger) Error

func (l *Logger) Error(format string, v ...interface{})

Error logs an error message with red color

func (*Logger) Info

func (l *Logger) Info(format string, v ...interface{})

Info logs an info message with green color

func (*Logger) MultiColor added in v1.1.0

func (l *Logger) MultiColor(level LogLevel, segments ...ColoredSegment)

MultiColor logs a message with multiple color segments

func (*Logger) Warn added in v1.3.0

func (l *Logger) Warn(format string, v ...interface{})

Warn logs a warning message with yellow color

type Option added in v1.1.0

type Option func(*Logger)

Option is a functional option for configuring the logger

func WithLogLevel added in v1.3.0

func WithLogLevel(level LogLevel) Option

WithLogLevel sets the logging level

func WithTimestamp added in v1.1.0

func WithTimestamp() Option

WithTimestamp enables timestamps in log output

Jump to

Keyboard shortcuts

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