logging

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(msg string, args ...any)

func Error

func Error(msg string, args ...any)

func Fatal

func Fatal(msg string, args ...any)

func Info

func Info(msg string, args ...any)

func InitConfig

func InitConfig(cfg Config)

func RequestIDFromContext

func RequestIDFromContext(ctx context.Context) string

func Reset

func Reset()

func SetOutput

func SetOutput(w io.Writer)

func ValidateCore

func ValidateCore(level, format, output, filePath string) error

func Warn

func Warn(msg string, args ...any)

func WithExecutionContext

func WithExecutionContext(ctx context.Context, value ExecutionContext) context.Context

func WithRequestID

func WithRequestID(ctx context.Context, requestID string) context.Context

func WriteBanner

func WriteBanner(w io.Writer)

Types

type ColorMode

type ColorMode int
const (
	AutoColor ColorMode = iota
	EnabledColor
	DisabledColor
)

type Config

type Config struct {
	Level            Level
	Mode             Mode
	Format           Format
	Color            ColorMode
	TimestampEnabled bool
	TimestampFormat  string
	ComponentWidth   int
	RequestIDWidth   int
	DefaultComponent string
	Output           io.Writer
	// contains filtered or unexported fields
}

func ConfigFromCore

func ConfigFromCore(level, format, output, filePath, env string, debug bool) (Config, error)

func DefaultConfig

func DefaultConfig() Config

func DevelopmentConfig

func DevelopmentConfig() Config

func ProductionConfig

func ProductionConfig() Config

type Entry

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

func (*Entry) Debug

func (e *Entry) Debug(msg string, args ...any)

func (*Entry) Error

func (e *Entry) Error(msg string, args ...any)

func (*Entry) Info

func (e *Entry) Info(msg string, args ...any)

func (*Entry) Warn

func (e *Entry) Warn(msg string, args ...any)

type ExecutionContext

type ExecutionContext string

func ExecutionContextFromContext

func ExecutionContextFromContext(ctx context.Context) ExecutionContext

type Format

type Format string
const (
	PrettyFormat  Format = "pretty"
	CompactFormat Format = "compact"
	JSONFormat    Format = "json"
)

type Level

type Level int
const (
	DebugLevel Level = iota
	InfoLevel
	WarnLevel
	ErrorLevel
)

func ParseLevel

func ParseLevel(value string, debug bool) Level

func (Level) String

func (l Level) String() string

type Logger

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

func For

func For(component string) *Logger

func Get

func Get() *Logger

func (*Logger) Component

func (l *Logger) Component() string

func (*Logger) Ctx

func (l *Logger) Ctx(ctx context.Context) *Entry

func (*Logger) Debug

func (l *Logger) Debug(msg string, args ...any)

func (*Logger) Enabled

func (l *Logger) Enabled(level Level) bool

func (*Logger) Error

func (l *Logger) Error(msg string, args ...any)

func (*Logger) Info

func (l *Logger) Info(msg string, args ...any)

func (*Logger) Warn

func (l *Logger) Warn(msg string, args ...any)

type Mode

type Mode string
const (
	DevelopmentMode Mode = "development"
	ProductionMode  Mode = "production"
)

type Record

type Record struct {
	Time             time.Time
	Level            Level
	ExecutionContext string
	RequestID        string
	Component        string
	Message          string
}

Jump to

Keyboard shortcuts

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