mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-18 20:30:51 +08:00
fix: Implement fallback log directory for file logging on read-only systems.
This commit is contained in:
@@ -95,6 +95,13 @@ func ConfigureLogOutput(loggingToFile bool, logsMaxTotalSizeMB int) error {
|
|||||||
logDir := "logs"
|
logDir := "logs"
|
||||||
if base := util.WritablePath(); base != "" {
|
if base := util.WritablePath(); base != "" {
|
||||||
logDir = filepath.Join(base, "logs")
|
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 := ""
|
protectedPath := ""
|
||||||
|
|||||||
Reference in New Issue
Block a user