mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-02 04:20:50 +08:00
feat(logging): make error-logs-max-files configurable
- Add ErrorLogsMaxFiles config field with default value 10 - Support hot-reload via config file changes - Add Management API: GET/PUT/PATCH /v0/management/error-logs-max-files - Maintain SDK backward compatibility with NewFileRequestLogger (3 params) - Add NewFileRequestLoggerWithOptions for custom error log retention When request logging is disabled, forced error logs are retained up to the configured limit. Set to 0 to disable cleanup.
This commit is contained in:
@@ -205,7 +205,7 @@ func main() {
|
||||
// Optional: add a simple middleware + custom request logger
|
||||
api.WithMiddleware(func(c *gin.Context) { c.Header("X-Example", "custom-provider"); c.Next() }),
|
||||
api.WithRequestLoggerFactory(func(cfg *config.Config, cfgPath string) logging.RequestLogger {
|
||||
return logging.NewFileRequestLogger(true, "logs", filepath.Dir(cfgPath))
|
||||
return logging.NewFileRequestLoggerWithOptions(true, "logs", filepath.Dir(cfgPath), cfg.ErrorLogsMaxFiles)
|
||||
}),
|
||||
).
|
||||
WithHooks(hooks).
|
||||
|
||||
Reference in New Issue
Block a user