feat(config, usage): add usage-statistics-enabled option and dynamic toggling

- Introduced `usage-statistics-enabled` configuration to control in-memory usage aggregation.
- Updated API to include handlers for managing `usage-statistics-enabled` and `logging-to-file` options.
- Enhanced `watcher` to log changes to both configurations dynamically.
- Updated documentation and examples to reflect new configuration options.
This commit is contained in:
Luis Pater
2025-09-26 03:19:44 +08:00
parent 483229779c
commit 25ba042493
9 changed files with 79 additions and 0 deletions

View File

@@ -26,6 +26,9 @@ type Config struct {
// LoggingToFile controls whether application logs are written to rotating files or stdout.
LoggingToFile bool `yaml:"logging-to-file" json:"logging-to-file"`
// UsageStatisticsEnabled toggles in-memory usage aggregation; when false, usage data is discarded.
UsageStatisticsEnabled bool `yaml:"usage-statistics-enabled" json:"usage-statistics-enabled"`
// ProxyURL is the URL of an optional proxy server to use for outbound requests.
ProxyURL string `yaml:"proxy-url" json:"proxy-url"`
@@ -206,6 +209,7 @@ func LoadConfig(configFile string) (*Config, error) {
var config Config
// Set defaults before unmarshal so that absent keys keep defaults.
config.LoggingToFile = true
config.UsageStatisticsEnabled = true
config.GeminiWeb.Context = true
if err = yaml.Unmarshal(data, &config); err != nil {
return nil, fmt.Errorf("failed to parse config file: %w", err)