log

package
v3.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: MIT Imports: 11 Imported by: 10

Documentation

Index

Constants

View Source
const (
	Ldate         int = log.Ldate         // Print the date in the local time zone
	Ltime         int = log.Ltime         // Print the time in the local time zone
	Lmicroseconds int = log.Lmicroseconds // Print the time with microsecond precision
	Llongfile     int = log.Llongfile     // Print full file name and line number
	Lshortfile    int = log.Lshortfile    // Print final file name element and line number
	LUTC          int = log.LUTC          // Print date and time in UTC
	Lmsgprefix    int = log.Lmsgprefix    // Move the prefix from the beginning of the line to before the message
	LstdFlags     int = log.LstdFlags     // Standard flags: Ldate | Ltime
)

Log flags that control the output format

Variables

View Source
var (
	DEBUG  atomic.Bool             // Global debug flag (default false)
	Output io.Writer   = os.Stderr // Default output writer
	Prefix string      = ""        // Default prefix for all loggers
	Flags  int         = 0         // Default flags for all loggers
)

Global configuration variables

Functions

func SetDefault

func SetDefault(l *Log)

Types

type Log

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

Log represents a logger instance with enhanced functionality

func Default

func Default() *Log

Default returns the default Log.

func NewLog

func NewLog(prefix string) *Log

NewLog creates a new logger instance with the specified prefix

func (*Log) Debug

func (d *Log) Debug(message string, args ...any)

Debug is an alias for Debugf

func (*Log) Debugf

func (d *Log) Debugf(message string, args ...any)

Debugf prints a formatted message with debug color if debug mode is enabled

func (*Log) Default

func (d *Log) Default(message string, args ...any)

Default is an alias for Defaultf

func (*Log) Defaultf

func (d *Log) Defaultf(message string, args ...any)

Defaultf prints a formatted message with default color

func (*Log) Error

func (d *Log) Error(message string, args ...any)

Error is an alias for Errorf

func (*Log) Errorf

func (d *Log) Errorf(message string, args ...any)

Errorf prints a formatted message with error color

func (*Log) Fatal

func (d *Log) Fatal(message string, args ...any)

Fatal is an alias for Fatalf

func (*Log) Fatalf

func (d *Log) Fatalf(message string, args ...any)

Fatalf prints a formatted message with error color and exits the program

func (*Log) Info

func (d *Log) Info(message string, args ...any)

Info is an alias for Infof

func (*Log) Infof

func (d *Log) Infof(message string, args ...any)

Infof prints a formatted message with info color

func (*Log) Prefix

func (d *Log) Prefix() string

Prefix returns the current logger prefix

func (*Log) Println

func (d *Log) Println(message string, args ...any)

Println is an alias for Printlnf

func (*Log) Printlnf

func (d *Log) Printlnf(message string, args ...any)

Printlnf prints a formatted message with color support

func (*Log) Question

func (d *Log) Question(message string, args ...any)

Question is an alias for Questionf

func (*Log) Questionf

func (d *Log) Questionf(message string, args ...any)

Questionf prints a formatted message with question color

func (*Log) Secondary

func (d *Log) Secondary(message string, args ...any)

Secondary is an alias for Secondaryf

func (*Log) Secondaryf

func (d *Log) Secondaryf(message string, args ...any)

Secondaryf prints a formatted message with secondary color

func (*Log) SetPrefix

func (d *Log) SetPrefix(prefix string)

SetPrefix sets a new prefix for the logger

func (*Log) Success

func (d *Log) Success(message string, args ...any)

Success is an alias for Successf

func (*Log) Successf

func (d *Log) Successf(message string, args ...any)

Successf prints a formatted message with success color

func (*Log) Warning

func (d *Log) Warning(message string, args ...any)

Warning is an alias for Warningf

func (*Log) Warningf

func (d *Log) Warningf(message string, args ...any)

Warningf prints a formatted message with warning color

type PrefixSimpleHandler

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

func NewPrefixSimpleHandler

func NewPrefixSimpleHandler(w io.Writer, prefix string) *PrefixSimpleHandler

func (*PrefixSimpleHandler) Enabled

func (h *PrefixSimpleHandler) Enabled(_ context.Context, _ slog.Level) bool

func (*PrefixSimpleHandler) Handle

func (*PrefixSimpleHandler) SetPrefix

func (h *PrefixSimpleHandler) SetPrefix(prefix string)

func (*PrefixSimpleHandler) WithAttrs

func (h *PrefixSimpleHandler) WithAttrs(attrs []slog.Attr) slog.Handler

func (*PrefixSimpleHandler) WithGroup

func (h *PrefixSimpleHandler) WithGroup(name string) slog.Handler

Jump to

Keyboard shortcuts

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