Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/fuse-daemon/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ go 1.26.1

require github.com/hanwen/go-fuse/v2 v2.9.0

require golang.org/x/sys v0.28.0 // indirect
require (
golang.org/x/sys v0.28.0 // indirect
gopkg.in/lumberjack.v2 v2.0.0 // indirect
)
2 changes: 2 additions & 0 deletions packages/fuse-daemon/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ github.com/moby/sys/mountinfo v0.7.2 h1:1shs6aH5s4o5H2zQLn796ADW1wMrIwHsyJ2v9Kou
github.com/moby/sys/mountinfo v0.7.2/go.mod h1:1YOa8w8Ih7uW0wALDUgT1dTTSBrZ+HiBLGws92L2RU4=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
gopkg.in/lumberjack.v2 v2.0.0 h1:IDj6hi8KbNiPQ5VaYNFZ7dBJLF5LFeKvsFrWHjA5aq4=
gopkg.in/lumberjack.v2 v2.0.0/go.mod h1:bp5nQ2kK/lLQSmTk29azj9+JB6bWci56xFn/lvd5GLI=
18 changes: 11 additions & 7 deletions packages/fuse-daemon/internal/logger/logger.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
package logger

import (
"fmt"
"log/slog"
"os"

"gopkg.in/lumberjack.v2"
)

func New(logFilePath string) *slog.Logger {
f, err := os.OpenFile(logFilePath, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0644)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to open log file %s: %v\n", logFilePath, err)
os.Exit(1)

rotatingWriter := &lumberjack.Logger{
Filename: logFilePath,
MaxSize: 500, // MB
MaxBackups: 3,
MaxAge: 30, // days
Compress: true,
}

return slog.New(slog.NewJSONHandler(f, &slog.HandlerOptions{
return slog.New(slog.NewJSONHandler(rotatingWriter, &slog.HandlerOptions{
Level: slog.LevelDebug,
}))
}
Loading