mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-18 04:10:51 +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:
@@ -3,6 +3,8 @@ package logging
|
||||
|
||||
import internallogging "github.com/router-for-me/CLIProxyAPI/v6/internal/logging"
|
||||
|
||||
const defaultErrorLogsMaxFiles = 10
|
||||
|
||||
// RequestLogger defines the interface for logging HTTP requests and responses.
|
||||
type RequestLogger = internallogging.RequestLogger
|
||||
|
||||
@@ -12,7 +14,12 @@ type StreamingLogWriter = internallogging.StreamingLogWriter
|
||||
// FileRequestLogger implements RequestLogger using file-based storage.
|
||||
type FileRequestLogger = internallogging.FileRequestLogger
|
||||
|
||||
// NewFileRequestLogger creates a new file-based request logger.
|
||||
// NewFileRequestLogger creates a new file-based request logger with default error log retention (10 files).
|
||||
func NewFileRequestLogger(enabled bool, logsDir string, configDir string) *FileRequestLogger {
|
||||
return internallogging.NewFileRequestLogger(enabled, logsDir, configDir)
|
||||
return internallogging.NewFileRequestLogger(enabled, logsDir, configDir, defaultErrorLogsMaxFiles)
|
||||
}
|
||||
|
||||
// NewFileRequestLoggerWithOptions creates a new file-based request logger with configurable error log retention.
|
||||
func NewFileRequestLoggerWithOptions(enabled bool, logsDir string, configDir string, errorLogsMaxFiles int) *FileRequestLogger {
|
||||
return internallogging.NewFileRequestLogger(enabled, logsDir, configDir, errorLogsMaxFiles)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user