log

package
v0.1.18 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogSubDir        = "logs"
	LLMLogFilePrefix = "llm"
	AppLogFilePrefix = "app"
)
View Source
const DefaultLogRetentionDays = 30

DefaultLogRetentionDays is the default number of days to keep log files.

Variables

This section is empty.

Functions

func ListLogFiles

func ListLogFiles(dataDir, prefix string) ([]fs.FileInfo, error)

ListLogFiles returns log file names matching the given prefix, sorted by date descending.

func LogDir

func LogDir(dataDir string) string

LogDir returns the full path to the log subdirectory.

func NewLLMLogger

func NewLLMLogger(dataDir string) (*slog.Logger, error)

NewLLMLogger creates a dedicated JSON logger for LLM request/response logging.

func NewLLMWriter added in v0.1.9

func NewLLMWriter(dataDir string) (io.Writer, error)

NewLLMWriter creates a rotating file writer for LLM trace JSONL logging.

func SetRetentionDays

func SetRetentionDays(days int)

SetRetentionDays configures how many days of log files to keep. Must be called before creating any DailyRotateWriter.

func SetupDefaultLogger

func SetupDefaultLogger(dataDir string) error

SetupDefaultLogger configures the global slog logger to write to a daily-rotating file and stderr simultaneously.

Types

type DailyRotateWriter

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

DailyRotateWriter writes log output to date-named files and rotates daily. File naming: {prefix}-{YYYY-MM-DD}.log

func NewDailyRotateWriter

func NewDailyRotateWriter(dir, prefix string) (*DailyRotateWriter, error)

NewDailyRotateWriter creates a writer that rotates files daily under dir/LogSubDir/.

func (*DailyRotateWriter) Close

func (w *DailyRotateWriter) Close() error

Close closes the current log file.

func (*DailyRotateWriter) Write

func (w *DailyRotateWriter) Write(p []byte) (int, error)

Write implements io.Writer. It rotates the file when the date changes.

func (*DailyRotateWriter) WriteWithOffset added in v0.1.9

func (w *DailyRotateWriter) WriteWithOffset(p []byte) (n int, offset int64, err error)

WriteWithOffset writes p and returns the file offset before the write. The offset is the byte position of p in the current day's log file.

Jump to

Keyboard shortcuts

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