chore(docs): add and refine package-level comments across modules

- Added detailed package-level comments to improve documentation coverage.
- Clarified parameter descriptions, return types, and functionality of exported methods across packages.
- Enhanced overall code readability and API documentation consistency.
This commit is contained in:
Luis Pater
2025-09-25 00:14:17 +08:00
parent 3c5390a87e
commit 0db0b03db9
18 changed files with 411 additions and 43 deletions

View File

@@ -1,3 +1,6 @@
// Package usage provides usage tracking and logging functionality for the CLI Proxy API server.
// It includes plugins for monitoring API usage, token consumption, and other metrics
// to help with observability and billing purposes.
package usage
import (
@@ -13,12 +16,23 @@ func init() {
}
// LoggerPlugin outputs every usage record to the application log.
// It implements the coreusage.Plugin interface to provide usage tracking
// and logging capabilities for monitoring API consumption.
type LoggerPlugin struct{}
// NewLoggerPlugin constructs a new logger plugin instance.
//
// Returns:
// - *LoggerPlugin: A new logger plugin instance
func NewLoggerPlugin() *LoggerPlugin { return &LoggerPlugin{} }
// HandleUsage implements coreusage.Plugin.
// It processes usage records by marshaling them to JSON and logging them
// at debug level for observability purposes.
//
// Parameters:
// - ctx: The context for the usage record
// - record: The usage record to process and log
func (p *LoggerPlugin) HandleUsage(ctx context.Context, record coreusage.Record) {
// Output all relevant fields for observability; keep logging lightweight and non-blocking.
data, _ := json.Marshal(record)