log

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Global = defaultLogger

Global logger for use throughout the application

Functions

func Debug

func Debug(format string, args ...interface{})

Debug logs a debug message to the default logger

func Debugf

func Debugf(format string, args ...interface{})

Debugf logs a formatted debug message

func Error

func Error(format string, args ...interface{})

Error logs an error message to the default logger

func Errorf

func Errorf(format string, args ...interface{})

Errorf logs a formatted error message

func ExportLogger

func ExportLogger() *log.Logger

ExportLogger exports the logger for use by CGO or other packages

func Fatal

func Fatal(format string, args ...interface{})

Fatal logs a fatal message to the default logger and exits

func Fatalf

func Fatalf(format string, args ...interface{})

Fatalf logs a formatted fatal message and exits

func Info

func Info(format string, args ...interface{})

Info logs an info message to the default logger

func Infof

func Infof(format string, args ...interface{})

Infof logs a formatted info message

func Initialize

func Initialize(opts *Options)

Initialize initializes the global logger with options

func SetColorful

func SetColorful(colorful bool)

SetColorful enables or disables colored output

func SetLevel

func SetLevel(level Level)

SetLevel sets the default logger level

func SetOutput

func SetOutput(w io.Writer)

SetOutput sets the default logger output

func SetPrefix

func SetPrefix(prefix string)

SetPrefix sets the default logger prefix

func UseLogger

func UseLogger(l *Logger)

UseLogger sets the default logger

func Warn

func Warn(format string, args ...interface{})

Warn logs a warning message to the default logger

func Warnf

func Warnf(format string, args ...interface{})

Warnf logs a formatted warning message

Types

type Level

type Level int

Level represents log level

const (
	LevelDebug Level = iota
	LevelInfo
	LevelWarn
	LevelError
	LevelFatal
)

func (Level) Color

func (l Level) Color() string

Color returns the ANSI color code for the level

func (Level) String

func (l Level) String() string

String returns the string representation of log level

type Logger

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

Logger is the application logger

func Default

func Default() *Logger

Default returns the default logger

func DiscardLogger

func DiscardLogger() *Logger

DiscardLogger returns a logger that discards all output

func New

func New(opts *Options) *Logger

New creates a new logger

func StderrLogger

func StderrLogger() *Logger

StderrLogger returns a logger that writes to stderr

func WithLevel

func WithLevel(level Level) *Logger

WithLevel returns a new logger with the specified level

func WithOutput

func WithOutput(w io.Writer) *Logger

WithOutput returns a new logger with the specified output

func WithPrefix

func WithPrefix(prefix string) *Logger

WithPrefix returns a new logger with the specified prefix

func (*Logger) Debug

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

Debug logs a debug message

func (*Logger) Debugf

func (l *Logger) Debugf(format string, args ...interface{})

Debugf logs a formatted debug message

func (*Logger) Error

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

Error logs an error message

func (*Logger) Errorf

func (l *Logger) Errorf(format string, args ...interface{})

Errorf logs a formatted error message

func (*Logger) Fatal

func (l *Logger) Fatal(format string, args ...interface{})

Fatal logs a fatal message and exits

func (*Logger) Fatalf

func (l *Logger) Fatalf(format string, args ...interface{})

Fatalf logs a formatted fatal message and exits

func (*Logger) Info

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

Info logs an info message

func (*Logger) Infof

func (l *Logger) Infof(format string, args ...interface{})

Infof logs a formatted info message

func (*Logger) SetColorful

func (l *Logger) SetColorful(colorful bool)

SetColorful enables or disables colored output

func (*Logger) SetLevel

func (l *Logger) SetLevel(level Level)

SetLevel sets the log level

func (*Logger) SetOutput

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

SetOutput sets the output writer

func (*Logger) SetPrefix

func (l *Logger) SetPrefix(prefix string)

SetPrefix sets the log prefix

func (*Logger) Warn

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

Warn logs a warning message

func (*Logger) Warnf

func (l *Logger) Warnf(format string, args ...interface{})

Warnf logs a formatted warning message

type Options

type Options struct {
	Level    Level
	Output   io.Writer
	Prefix   string
	TimeFmt  string
	Colorful bool
}

Options configures the logger

func DefaultOptions

func DefaultOptions() *Options

DefaultOptions returns default logger options

Jump to

Keyboard shortcuts

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