Documentation
¶
Index ¶
- Constants
- func ListLogFiles(dataDir, prefix string) ([]fs.FileInfo, error)
- func LogDir(dataDir string) string
- func NewLLMLogger(dataDir string) (*slog.Logger, error)
- func NewLLMWriter(dataDir string) (io.Writer, error)
- func SetRetentionDays(days int)
- func SetupDefaultLogger(dataDir string) error
- type DailyRotateWriter
Constants ¶
const ( LogSubDir = "logs" LLMLogFilePrefix = "llm" AppLogFilePrefix = "app" )
const DefaultLogRetentionDays = 30
DefaultLogRetentionDays is the default number of days to keep log files.
Variables ¶
This section is empty.
Functions ¶
func ListLogFiles ¶
ListLogFiles returns log file names matching the given prefix, sorted by date descending.
func NewLLMLogger ¶
NewLLMLogger creates a dedicated JSON logger for LLM request/response logging.
func NewLLMWriter ¶ added in v0.1.9
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 ¶
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.