feat(config): add logging configuration fields

This commit is contained in:
Alexander
2026-04-10 18:15:49 +02:00
parent a7b583839d
commit bfcbe0b37d
2 changed files with 31 additions and 0 deletions
+8
View File
@@ -45,3 +45,11 @@ sanitize:
replace: "claude.ai"
- match: "opencode"
replace: "agent"
logging:
level: info
# file: /var/log/anthropic-proxy.log # omit to log to stderr
# max_size_mb: 100
# max_backups: 5
# max_age_days: 30
# compress: true
+23
View File
@@ -15,6 +15,7 @@ type Config struct {
APIKeys []string `yaml:"api_keys"`
ClaudeBinary string `yaml:"claude_binary"`
Sanitize SanitizeConfig `yaml:"sanitize"`
Logging LoggingConfig `yaml:"logging"`
}
type SanitizeConfig struct {
@@ -33,6 +34,15 @@ type ReplaceRule struct {
Replace string `yaml:"replace"`
}
type LoggingConfig struct {
Level string `yaml:"level"`
File string `yaml:"file"`
MaxSizeMB int `yaml:"max_size_mb"`
MaxBackups int `yaml:"max_backups"`
MaxAgeDays int `yaml:"max_age_days"`
Compress bool `yaml:"compress"`
}
type claudeCredentialsJSON struct {
ClaudeAiOauth struct {
AccessToken string `json:"accessToken"`
@@ -53,6 +63,19 @@ func Load(path string) (*Config, error) {
return nil, fmt.Errorf("parse config: %w", err)
}
if cfg.Logging.Level == "" {
cfg.Logging.Level = "info"
}
if cfg.Logging.MaxSizeMB == 0 {
cfg.Logging.MaxSizeMB = 100
}
if cfg.Logging.MaxBackups == 0 {
cfg.Logging.MaxBackups = 5
}
if cfg.Logging.MaxAgeDays == 0 {
cfg.Logging.MaxAgeDays = 30
}
// Check for deprecated claude_credentials field
var rawCfg map[string]interface{}
if err := yaml.Unmarshal(data, &rawCfg); err == nil {