logger

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2025 License: MIT Imports: 7 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Level      Level
	Output     io.Writer
	LogToFile  bool
	LogFile    string
	TimeFormat string
}

Config holds configuration for the logger

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a default logger configuration

type Level

type Level int

Level represents the logging level

const (
	LevelDebug Level = iota
	LevelInfo
	LevelError
)

func (Level) String

func (l Level) String() string

String returns the string representation of the log level

type Logger

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

Logger implements the interfaces.Logger interface with configurable output and levels

func NewDualLogger

func NewDualLogger(level Level, logFile string) (*Logger, error)

NewDualLogger creates a logger that outputs to both stdout and a file

func NewFileLogger

func NewFileLogger(level Level, logFile string) (*Logger, error)

NewFileLogger creates a logger that outputs to a file with the given level

func NewInternalLogger

func NewInternalLogger(level Level, cacheDir string) (*Logger, error)

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 NewLogger

func NewLogger(config *Config) (*Logger, error)

NewLogger creates a new logger with the given configuration

func NewSimpleLogger

func NewSimpleLogger(level Level) *Logger

NewSimpleLogger creates a logger that outputs to stdout with the given level

func (*Logger) Close

func (l *Logger) Close() error

Close closes any file handles if the logger is writing to a file

func (*Logger) Debug

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

Debug logs a debug message (implements interfaces.Logger)

func (*Logger) Error

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

Error logs an error message (implements interfaces.Logger)

func (*Logger) GetLevel

func (l *Logger) GetLevel() Level

GetLevel returns the current logging level

func (*Logger) Info

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

Info logs an info message (implements interfaces.Logger)

func (*Logger) SetLevel

func (l *Logger) SetLevel(level Level)

SetLevel changes the logging level

Jump to

Keyboard shortcuts

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