logging

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DebugLog

type DebugLog struct {
	// contains filtered or unexported fields
}

func NewDebugLog

func NewDebugLog(enabled bool, dir string) *DebugLog

func (*DebugLog) Body

func (d *DebugLog) Body(prefix string, body []byte)

func (*DebugLog) Close

func (d *DebugLog) Close()

func (*DebugLog) Headers

func (d *DebugLog) Headers(prefix string, h http.Header)

func (*DebugLog) IsEnabled

func (d *DebugLog) IsEnabled() bool

func (*DebugLog) Printf

func (d *DebugLog) Printf(format string, args ...any)

type TokenLogger

type TokenLogger struct {
	// contains filtered or unexported fields
}

func NewTokenLogger

func NewTokenLogger(cfg config.TokenLogConfig) (*TokenLogger, error)

func (*TokenLogger) Close

func (l *TokenLogger) Close()

func (*TokenLogger) DroppedEntries

func (l *TokenLogger) DroppedEntries() int64

DroppedEntries returns the total number of log entries dropped due to channel overflow.

func (*TokenLogger) Log

func (l *TokenLogger) Log(entry UsageLog)

func (*TokenLogger) Mode

func (l *TokenLogger) Mode() string

func (*TokenLogger) Path

func (l *TokenLogger) Path() string

func (*TokenLogger) QueryUsageLogs

func (l *TokenLogger) QueryUsageLogs(filter UsageLogFilter) ([]UsageLog, UsageLogSummary, error)

type UsageInfo

type UsageInfo struct {
	ResponseModel    string
	PromptTokens     int
	CompletionTokens int
	TotalTokens      int
	InputTokens      int
	OutputTokens     int
}

func ExtractStreamingUsage

func ExtractStreamingUsage(protocol string, data []byte) (UsageInfo, bool)

func ExtractUsage

func ExtractUsage(protocol string, body []byte) UsageInfo

type UsageLog

type UsageLog struct {
	Time             string `json:"time"`
	RequestID        string `json:"request_id,omitempty"`
	Backend          string `json:"backend"`
	ClientProtocol   string `json:"client_protocol"`
	BackendProtocol  string `json:"backend_protocol"`
	ClientKey        string `json:"client_key"`
	RequestModel     string `json:"request_model,omitempty"`
	ForwardedModel   string `json:"forwarded_model,omitempty"`
	ResponseModel    string `json:"response_model,omitempty"`
	StatusCode       int    `json:"status_code"`
	DurationMs       int64  `json:"duration_ms,omitempty"`
	RetryCount       int    `json:"retry_count,omitempty"`
	ErrorCategory    string `json:"error_category,omitempty"`
	Transport        string `json:"transport,omitempty"`
	PromptTokens     int    `json:"prompt_tokens,omitempty"`
	CompletionTokens int    `json:"completion_tokens,omitempty"`
	TotalTokens      int    `json:"total_tokens,omitempty"`
	InputTokens      int    `json:"input_tokens,omitempty"`
	OutputTokens     int    `json:"output_tokens,omitempty"`
	Error            string `json:"error,omitempty"`
}

type UsageLogFilter

type UsageLogFilter struct {
	Limit         int
	Offset        int
	ClientKey     string
	Backend       string
	StatusCode    int
	ErrorCategory string
	StartTime     string
	EndTime       string
}

type UsageLogSummary

type UsageLogSummary struct {
	TotalRequests int `json:"total_requests"`
	TotalTokens   int `json:"total_tokens"`
	ErrorCount    int `json:"error_count"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL