fix: Return an error if the user home directory cannot be determined for the fallback log path.

This commit is contained in:
Soff
2025-12-29 18:46:15 +08:00
committed by GitHub
parent 6705d20194
commit 44b63f0767

View File

@@ -99,9 +99,11 @@ func ConfigureLogOutput(loggingToFile bool, logsMaxTotalSizeMB int) error {
// 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")
home, err := os.UserHomeDir()
if err != nil {
return fmt.Errorf("logging: failed to determine user home directory for fallback log path: %w", err)
}
logDir = filepath.Join(home, ".cliproxyapi", "logs")
}
protectedPath := ""