logging

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

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

Convenience functions that use the global logger

func Error

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

func Fatal

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

Fatal logs an error message and exits the program

func GetDebugFilePath added in v0.1.6

func GetDebugFilePath(defaultFileName string) string

GetDebugFilePath returns the debug file path from environment variable or default

func Info

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

func LogError

func LogError(ctx context.Context, logger Logger, msg string, err error, args ...any)

Context helpers for structured error logging

func LogErrorWithOperation

func LogErrorWithOperation(ctx context.Context, logger Logger, operation, msg string, err error, args ...any)

func SetGlobalLogger

func SetGlobalLogger(logger Logger)

SetGlobalLogger sets the global logger instance

func Warn

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

Types

type Config

type Config struct {
	Level   slog.Level
	Format  Format
	Output  io.Writer
	AddTime bool
}

Config holds logger configuration

type Format

type Format int

Format represents the output format

const (
	FormatText Format = iota
	FormatJSON
)

type Logger

type Logger interface {
	Debug(msg string, args ...any)
	Info(msg string, args ...any)
	Warn(msg string, args ...any)
	Error(msg string, args ...any)
	With(args ...any) Logger
	WithGroup(name string) Logger
	SetLevel(level slog.Level) // Add method for dynamic level changes
}

Logger interface for dependency injection and testing

func GetGlobalLogger

func GetGlobalLogger() Logger

GetGlobalLogger returns the global logger instance

func NewAPILogger

func NewAPILogger(service string) Logger

API logger for HTTP/GRPC requests

func NewComponentLogger

func NewComponentLogger(component string) Logger

Component logger helpers for common use cases

func NewDefaultLogger

func NewDefaultLogger() Logger

NewDefaultLogger creates a logger with sensible defaults for CLI tools

func NewDisabledLogger added in v0.1.6

func NewDisabledLogger() Logger

NewDisabledLogger creates a logger that discards all output (useful for tests)

func NewFileLoggerFromEnv added in v0.1.6

func NewFileLoggerFromEnv(defaultFileName string) Logger

NewFileLoggerFromEnv creates a file-based logger using standard environment variables Uses GENIE_DEBUG_FILE for file path (defaults to temp file) and GENIE_DEBUG_LEVEL for level

func NewLogger

func NewLogger(config Config) Logger

NewLogger creates a new logger with the given configuration

func NewOperationLogger

func NewOperationLogger(component, operation string) Logger

Operation logger for tracking operations with duration

func NewPromptLogger

func NewPromptLogger(promptName string) Logger

Prompt logger specifically for AI prompt operations

func NewQuietLogger

func NewQuietLogger() Logger

NewQuietLogger creates a logger that only shows errors

func NewVerboseLogger

func NewVerboseLogger() Logger

NewVerboseLogger creates a logger that shows debug information

Jump to

Keyboard shortcuts

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