feat(config): add logging configuration fields
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user