Documentation
¶
Overview ¶
Package logger provides a comprehensive logging system designed for TUI applications. It supports multiple log levels, file-based logging, and configurable output destinations. The logger is designed to avoid stdout interference with terminal user interfaces.
Index ¶
- func GetGlobalLogger() interfaces.Logger
- func GetPackageLogger(packageName string) interfaces.Logger
- func InitGlobalLogger(level Level, cacheDir string) error
- func InitGlobalLoggerWithValidation(level Level, cacheDir string) error
- func SetDebugEnabled(enabled bool)
- type Config
- type Level
- type Logger
- func GetPackageLoggerConcrete(packageName string) *Logger
- func NewDualLogger(level Level, logFile string) (*Logger, error)
- func NewFileLogger(level Level, logFile string) (*Logger, error)
- func NewInternalLogger(level Level, cacheDir string) (*Logger, error)
- func NewLogger(config *Config) (*Logger, error)
- func NewSimpleLogger(level Level) *Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetGlobalLogger ¶
func GetGlobalLogger() interfaces.Logger
GetGlobalLogger returns the global logger instance If not initialized, it creates a simple logger with Info level.
func GetPackageLogger ¶
func GetPackageLogger(packageName string) interfaces.Logger
GetPackageLogger returns a logger for a specific package using the global cache directory This ensures all packages log to the same unified log file.
func InitGlobalLogger ¶
InitGlobalLogger initializes the global logger with the specified cache directory This should be called early in application initialization.
func InitGlobalLoggerWithValidation ¶
InitGlobalLoggerWithValidation initializes the global logger with cache directory validation This is a convenience function that validates the cache directory before initializing.
func SetDebugEnabled ¶
func SetDebugEnabled(enabled bool)
SetDebugEnabled sets the global debug flag for the logger package. This should be called during application initialization to enable debug logging.
Types ¶
type Config ¶
Config holds configuration for the logger.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a default logger configuration.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger implements the interfaces.Logger interface with configurable output and levels.
func GetPackageLoggerConcrete ¶
GetPackageLoggerConcrete returns a concrete Logger instance for packages that need the specific type This ensures all packages log to the same unified log file while maintaining type compatibility.
func NewDualLogger ¶
NewDualLogger creates a logger that outputs to both stdout and a file.
func NewFileLogger ¶
NewFileLogger creates a logger that outputs to a file with the given level.
func NewInternalLogger ¶
NewInternalLogger creates a logger that stores logs in the specified cache directory This is designed for TUI applications where stdout logging would interfere with the UI.
func NewSimpleLogger ¶
NewSimpleLogger creates a logger that outputs to stdout with the given level.