mirror of
https://github.com/router-for-me/CLIProxyAPIPlus.git
synced 2026-03-21 16:40:22 +00:00
Merge pull request #772 from soffchen/main
fix: Implement fallback log directory for file logging on read-only system
This commit is contained in:
@@ -95,6 +95,15 @@ 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).
|
||||
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 := ""
|
||||
|
||||
Reference in New Issue
Block a user