fix: Implement fallback log directory for file logging on read-only systems.

This commit is contained in:
Soff Chen
2025-12-29 18:35:48 +08:00
parent a38a9c0b0f
commit 6705d20194

View File

@@ -95,6 +95,13 @@ func ConfigureLogOutput(loggingToFile bool, logsMaxTotalSizeMB int) error {
logDir := "logs"
if base := util.WritablePath(); base != "" {
logDir = filepath.Join(base, "logs")
} else if loggingToFile {
// When logging to file is enabled but WRITABLE_PATH is not set,
// use a default writable location to avoid errors on read-only filesystems
// (e.g., Homebrew installations on macOS).
if home, err := os.UserHomeDir(); err == nil {
logDir = filepath.Join(home, ".cliproxyapi", "logs")
}
}
protectedPath := ""