{"record":{"id":"8215c6ac9c9c7712","repo":"router-for-me/CLIProxyAPI","slug":"logging-failed-to-create-log-directory-w","errorCode":null,"errorMessage":"logging: failed to create log directory: %w","messagePattern":"logging: failed to create log directory: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/logging/global_logger.go","lineNumber":197,"sourceCode":"\t}\n\treturn logDir\n}\n\n// ConfigureLogOutput switches the global log destination between rotating files and stdout.\n// When logsMaxTotalSizeMB > 0, a background cleaner removes the oldest log files in the logs directory\n// until the total size is within the limit.\nfunc ConfigureLogOutput(cfg *config.Config) error {\n\tSetupBaseLogger()\n\n\twriterMu.Lock()\n\tdefer writerMu.Unlock()\n\n\tlogDir := ResolveLogDirectory(cfg)\n\n\tprotectedPath := \"\"\n\tif cfg.LoggingToFile {\n\t\tif err := os.MkdirAll(logDir, 0o755); err != nil {\n\t\t\treturn fmt.Errorf(\"logging: failed to create log directory: %w\", err)\n\t\t}\n\t\tif logWriter != nil {\n\t\t\t_ = logWriter.Close()\n\t\t}\n\t\tprotectedPath = filepath.Join(logDir, \"main.log\")\n\t\tlogWriter = &lumberjack.Logger{\n\t\t\tFilename:   protectedPath,\n\t\t\tMaxSize:    10,\n\t\t\tMaxBackups: 0,\n\t\t\tMaxAge:     0,\n\t\t\tCompress:   false,\n\t\t}\n\t\tlog.SetOutput(logWriter)\n\t} else {\n\t\tif logWriter != nil {\n\t\t\t_ = logWriter.Close()\n\t\t\tlogWriter = nil\n\t\t}","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/logging/global_logger.go#L179-L215","documentation":"Error \"logging: failed to create log directory: %w\" thrown in router-for-me/CLIProxyAPI.","triggerScenarios":"Thrown at internal/logging/global_logger.go:197 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the log directory path is writable and parent directories exist.","Check the wrapped error for permission failures and fix directory permissions."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}