Versions in this module Expand all Collapse all v0 v0.2.7 Nov 27, 2026 v0.2.6 Nov 23, 2026 Changes in this version + const APIKeyHashPrefixLength + const AttemptKindFailover + const AttemptKindPrimary + const AttemptKindRetry + const AuthMethodAPIKey + const AuthMethodExtension + const AuthMethodMasterKey + const AuthMethodNoKey + const BatchFlushThreshold + const CacheTypeExact + const CacheTypeSemantic + const CleanupInterval + const GuardrailActionAllow + const GuardrailActionBlock + const GuardrailActionFailure + const GuardrailActionRespond + const GuardrailActionWarn + const GuardrailFailModeClosed + const GuardrailFailModeOpen + const GuardrailTargetRequest + const GuardrailTargetResponse + const LiveEventRequestLogCompleted + const LiveEventRequestLogFailed + const LiveEventRequestLogFlushed + const LiveEventRequestLogPrefix + const LiveEventRequestLogRemoved + const LiveEventRequestLogStarted + const LiveEventRequestLogStream + const LiveEventRequestLogUpdated + const LogEntryKey + const LogEntryLivePublisherKey + const LogEntryResponseCapturedKey + const LogEntryStreamingKey + const MaxBodyCapture + const MaxContentCapture + const StatsIntervalDay + const StatsIntervalHour + var ErrPartialWrite = errors.New("partial write failure") + func BodyDocument(body any) any + func CaptureAttemptResponseBody(body []byte) any + func CaptureInternalJSONExchange(entry *LogEntry, ctx context.Context, method, path string, ...) + func CaptureLoggedBody(bodyBytes []byte) any + func EnrichEntry(c *echo.Context, model, provider string) + func EnrichEntryWithAttempts(c *echo.Context, attempts []AttemptSnapshot) + func EnrichEntryWithAuthKeyID(c *echo.Context, authKeyID string) + func EnrichEntryWithAuthMethod(c *echo.Context, method string) + func EnrichEntryWithCacheType(c *echo.Context, cacheType string) + func EnrichEntryWithCachedStreamResponse(c *echo.Context, path string, body []byte) + func EnrichEntryWithCapturedResponseBody(c *echo.Context, body any, truncated bool) + func EnrichEntryWithError(c *echo.Context, errorType, errorMessage string, errorCode ...string) + func EnrichEntryWithFailover(c *echo.Context, targetModel string) + func EnrichEntryWithGatewayError(c *echo.Context, gatewayErr *core.GatewayError) + func EnrichEntryWithGuardrailOutcomes(c *echo.Context, compute func() []GuardrailOutcomeSnapshot) + func EnrichEntryWithPendingRequestRevisions(c *echo.Context, compute func() []RequestRevisionSnapshot) + func EnrichEntryWithPrincipalID(c *echo.Context, principalID string) + func EnrichEntryWithRawRequestBody(c *echo.Context, body []byte) + func EnrichEntryWithRequestBody(c *echo.Context, body any) + func EnrichEntryWithRequestRevision(c *echo.Context, revision RequestRevisionSnapshot) + func EnrichEntryWithRequestedModel(c *echo.Context, requestedModel string) + func EnrichEntryWithResolvedRoute(c *echo.Context, resolvedModel, providerType, providerName string) + func EnrichEntryWithResponseBody(c *echo.Context, body any) + func EnrichEntryWithSessionID(c *echo.Context, sessionID string) + func EnrichEntryWithStream(c *echo.Context, stream bool) + func EnrichEntryWithUserPath(c *echo.Context, userPath string) + func EnrichEntryWithWorkflow(c *echo.Context, workflow *core.Workflow) + func EnrichLogEntryWithAttempts(entry *LogEntry, attempts []AttemptSnapshot) + func EnrichLogEntryWithFailover(entry *LogEntry, targetModel string) + func EnrichLogEntryWithRequestContext(entry *LogEntry, ctx context.Context) + func EnrichLogEntryWithResolvedRoute(entry *LogEntry, resolvedModel, providerType, providerName string) + func EnrichLogEntryWithWorkflow(entry *LogEntry, workflow *core.Workflow) + func HasRecordedError(c *echo.Context) bool + func IsAudioContentType(contentType string) bool + func IsEntryMarkedAsStreaming(c interface{ ... }) bool + func IsResponseBodyCapturedByHandler(c interface{ ... }) bool + func MarkEntryAsStreaming(c interface{ ... }, isStreaming bool) + func Middleware(logger LoggerInterface) echo.MiddlewareFunc + func NewAuthenticationEventRecorder(logger LoggerInterface) ext.AuthenticationEventRecorder + func NormalizeAuthMethod(method string) string + func PopulateRequestData(entry *LogEntry, req *http.Request, cfg Config) + func PopulateRequestHeaders(entry *LogEntry, headers http.Header) + func PopulateResponseData(entry *LogEntry, headers http.Header, body []byte, bodyTruncated bool, ...) + func PopulateResponseHeaders(entry *LogEntry, headers http.Header) + func RedactAttemptResponseHeaders(header http.Header) map[string]string + func RedactHeaders(headers map[string]string) map[string]string + type AttemptSnapshot struct + DurationNs int64 + ErrorCode string + ErrorMessage string + ErrorType string + Kind string + Model string + ProviderName string + ProviderType string + ResponseBody any + ResponseHeaders map[string]string + Seq int + StartedAt time.Time + StatusCode int + Success bool + func GateAttemptCapture(attempts []AttemptSnapshot, cfg Config) []AttemptSnapshot + type AudioBodyLog struct + Audio bool + Bytes int64 + ContentType string + MediaID string + Meta map[string]any + Stored bool + func BuildAudioResponseBody(capture *MediaCapture, contentType string, data []byte) AudioBodyLog + func BuildAudioUploadBody(capture *MediaCapture, contentType string, data []byte, meta map[string]any) AudioBodyLog + func BuildRelayedAudioResponseBody(w *MediaWriter) AudioBodyLog + type Config struct + BufferSize int + Enabled bool + FlushInterval time.Duration + LogAudioBodies bool + LogBodies bool + LogEmbeddingBodies bool + LogGuardrailSteps bool + LogHeaders bool + LogImageInputs bool + LogImageOutputs bool + LogRevisionBodies bool + OnlyModelInteractions bool + RetentionDays int + func (c Config) ForPath(path string) Config + type ConversationResult struct + AnchorID string + Entries []LogEntry + Truncated bool + type EntryPreview struct + RequestBodyCaptured bool + ResponseBodyCaptured bool + type FailoverSnapshot struct + TargetModel string + type GuardrailOutcomeSnapshot struct + Action string + Code string + Detail any + DroppedEvents int + DurationNs int64 + Edited bool + Error string + FailMode string + Instance string + Message string + Phase string + ReplacedEvents int + Seq int + Step int + Target string + Type string + type ImageBodyLog struct + Images bool + Items []ImageItemLog + Meta map[string]any + func BuildImageResponseBody(capture *MediaCapture, resp *core.ImageGenerationResponse) ImageBodyLog + func BuildImageUploadBody(capture *MediaCapture, images []core.ImageFile, mask *core.ImageFile, ...) ImageBodyLog + type ImageItemErrorLog struct + Code string + Message string + type ImageItemLog struct + Bytes int64 + ContentType string + Error *ImageItemErrorLog + Filename string + MediaID string + RevisedPrompt string + Role string + Size string + Stored bool + URL string + type InteractionParent struct + SessionID string + UserPath string + type LiveEventEmitter interface + PublishLiveEvent func(eventType string, entry *LogEntry) + type LiveEventPublisher interface + PublishRequestLogEvent func(eventType string, entry *LogEntry) + type LiveSubscriberReporter interface + HasLiveSubscribers func() bool + type LogData struct + APIKeyHash string + Attempts []AttemptSnapshot + ErrorCode string + ErrorMessage string + ErrorProvider string + EventType string + Failover *FailoverSnapshot + Guardrails []GuardrailOutcomeSnapshot + Labels []string + MaxTokens *int + RequestBody any + RequestBodyTooBigToHandle bool + RequestHeaders map[string]string + RequestRevisions []RequestRevisionSnapshot + ResponseBody any + ResponseBodyTooBigToHandle bool + ResponseHeaders map[string]string + Temperature *float64 + UserAgent string + WorkflowFeatures *WorkflowFeaturesSnapshot + type LogEntry struct + AliasUsed bool + AuthKeyID string + AuthMethod string + CacheType string + ClientIP string + Data *LogData + DurationNs int64 + ErrorType string + ID string + Method string + Path string + PrincipalID string + Provider string + ProviderName string + RequestID string + RequestedModel string + ResolvedModel string + SessionID string + Stamp *storage.WriteStamp + StatusCode int + Stream bool + Timestamp time.Time + UserPath string + WorkflowVersionID string + func CreateStreamEntry(ctx context.Context, baseEntry *LogEntry) *LogEntry + func GetStreamEntryFromContext(c interface{ ... }) *LogEntry + func (e *LogEntry) Complete() + func (e *LogEntry) CompleteRequestRevisions() + type LogListResult struct + Entries []LogEntry + Limit int + Offset int + Total int + type LogQueryParams struct + ErrorType string + ExactUserPath bool + ExcludeOperations []core.Operation + Limit int + Method string + ModelPrefix string + Offset int + OmitAttempts bool + Path string + Provider string + RequestID string + RequestedModel string + Search string + SessionID string + StatusCode *int + Stream *bool + UserPath string + UserPathPrefix string + type LogStore interface + Close func() error + Flush func(ctx context.Context) error + WriteBatch func(ctx context.Context, entries []*LogEntry) error + type Logger struct + func NewLogger(store LogStore, cfg Config) *Logger + func (l *Logger) Close() error + func (l *Logger) Config() Config + func (l *Logger) HasLiveSubscribers() bool + func (l *Logger) PublishLiveEvent(eventType string, entry *LogEntry) + func (l *Logger) SetLivePublisher(p LiveEventPublisher) + func (l *Logger) Write(entry *LogEntry) + type LoggerInterface interface + Close func() error + Config func() Config + Write func(entry *LogEntry) + type MediaCapture struct + func (m *MediaCapture) AudioWriter(contentType string) *MediaWriter + type MediaCapturer struct + func NewMediaCapturer(store *mediastore.Service, retentionDays int) *MediaCapturer + func (m *MediaCapturer) For(c *echo.Context) *MediaCapture + type MediaWriter struct + func (w *MediaWriter) Bytes() int64 + func (w *MediaWriter) Write(p []byte) (int, error) + type MongoDBReader struct + func NewMongoDBReader(database *mongo.Database) (*MongoDBReader, error) + func (r *MongoDBReader) GetConversation(ctx context.Context, logID string, limit int) (*ConversationResult, error) + func (r *MongoDBReader) GetInteractionParent(ctx context.Context, id string) (*InteractionParent, error) + func (r *MongoDBReader) GetLastUsedByAuthKeys(ctx context.Context, keyIDs []string) (map[string]time.Time, error) + func (r *MongoDBReader) GetLogByID(ctx context.Context, id string) (*LogEntry, error) + func (r *MongoDBReader) GetLogs(ctx context.Context, params LogQueryParams) (*LogListResult, error) + func (r *MongoDBReader) GetRequestStats(ctx context.Context, params RequestStatsParams) (*RequestStats, error) + func (r *MongoDBReader) GetSessions(ctx context.Context, params LogQueryParams) (*SessionListResult, error) + func (r *MongoDBReader) PreviewsByID(ctx context.Context, ids []string) ([]EntryPreview, error) + func (r *MongoDBReader) RecentWrites(ctx context.Context, since int64, excludeWriter string, limit int) ([]storage.RecentWrite, error) + type MongoDBStore struct + func NewMongoDBStore(database *mongo.Database, retentionDays int) (*MongoDBStore, error) + func (s *MongoDBStore) Close() error + func (s *MongoDBStore) Flush(_ context.Context) error + func (s *MongoDBStore) WriteBatch(ctx context.Context, entries []*LogEntry) error + type NoopLogger struct + func (l *NoopLogger) Close() error + func (l *NoopLogger) Config() Config + func (l *NoopLogger) Write(_ *LogEntry) + type PartialWriteError struct + Cause mongo.BulkWriteException + FailedCount int + TotalEntries int + func (e *PartialWriteError) Error() string + func (e *PartialWriteError) Unwrap() error + type ProviderLatencySeries struct + AvgDurationMs []*float64 + Provider string + Requests []int64 + type QueryParams struct + EndDate time.Time + StartDate time.Time + type Reader interface + GetConversation func(ctx context.Context, logID string, limit int) (*ConversationResult, error) + GetInteractionParent func(ctx context.Context, id string) (*InteractionParent, error) + GetLastUsedByAuthKeys func(ctx context.Context, keyIDs []string) (map[string]time.Time, error) + GetLogByID func(ctx context.Context, id string) (*LogEntry, error) + GetLogs func(ctx context.Context, params LogQueryParams) (*LogListResult, error) + GetRequestStats func(ctx context.Context, params RequestStatsParams) (*RequestStats, error) + GetSessions func(ctx context.Context, params LogQueryParams) (*SessionListResult, error) + func NewReader(store storage.Storage) (Reader, error) + type RecentWriteReader interface + PreviewsByID func(ctx context.Context, ids []string) ([]EntryPreview, error) + RecentWrites func(ctx context.Context, since int64, excludeWriter string, limit int) ([]storage.RecentWrite, error) + func NewRecentWriteReader(store storage.Storage) (RecentWriteReader, error) + type RequestRevisionSnapshot struct + Body any + BytesAfter int + BytesBefore int + Detail any + NoChange bool + Rewriter string + Seq int + TokensSaved int + type RequestStats struct + Buckets []RequestStatsBucket + Interval string + ProviderLatency []ProviderLatencySeries + Summary RequestStatsSummary + func EmptyRequestStats(interval string) *RequestStats + type RequestStatsBucket struct + Requests int64 + Start time.Time + Status2xx int64 + Status4xx int64 + Status5xx int64 + StatusOther int64 + type RequestStatsParams struct + Interval string + Location *time.Location + Now time.Time + UserPath string + type RequestStatsSummary struct + AvgDurationMs *float64 + Requests int64 + Status2xx int64 + Status4xx int64 + Status5xx int64 + StatusOther int64 + SuccessRate *float64 + type Result struct + Logger LoggerInterface + func New(ctx context.Context, cfg *config.Config, store storage.Storage) (*Result, error) + func (r *Result) Close() error + type SQLReader struct + func NewSQLReader(db sqlx.DB) (*SQLReader, error) + func (r *SQLReader) GetConversation(ctx context.Context, logID string, limit int) (*ConversationResult, error) + func (r *SQLReader) GetInteractionParent(ctx context.Context, id string) (*InteractionParent, error) + func (r *SQLReader) GetLastUsedByAuthKeys(ctx context.Context, keyIDs []string) (map[string]time.Time, error) + func (r *SQLReader) GetLogByID(ctx context.Context, id string) (*LogEntry, error) + func (r *SQLReader) GetLogs(ctx context.Context, params LogQueryParams) (*LogListResult, error) + func (r *SQLReader) GetRequestStats(ctx context.Context, params RequestStatsParams) (*RequestStats, error) + func (r *SQLReader) GetSessions(ctx context.Context, params LogQueryParams) (*SessionListResult, error) + func (r *SQLReader) PreviewsByID(ctx context.Context, ids []string) ([]EntryPreview, error) + func (r *SQLReader) RecentWrites(ctx context.Context, since int64, excludeWriter string, limit int) ([]storage.RecentWrite, error) + type SQLStore struct + func NewSQLStore(ctx context.Context, db sqlx.DB, retentionDays int) (*SQLStore, error) + func (s *SQLStore) Close() error + func (s *SQLStore) Flush(_ context.Context) error + func (s *SQLStore) WriteBatch(ctx context.Context, entries []*LogEntry) error + type SessionListResult struct + Limit int + Offset int + Sessions []SessionSummary + Total int + type SessionSummary struct + Latest LogEntry + RequestCount int + SessionID string + type StreamLogObserver struct + func NewStreamLogObserver(logger LoggerInterface, entry *LogEntry, path string) *StreamLogObserver + func (o *StreamLogObserver) OnJSONEvent(event map[string]any) + func (o *StreamLogObserver) OnStreamClose() + func (o *StreamLogObserver) WantsJSONEvent([]byte) bool + type WorkflowFeaturesSnapshot struct + Budget bool + Cache bool + Failover bool + Guardrails bool + RequestLogs bool + Usage bool + func (s *WorkflowFeaturesSnapshot) UnmarshalBSON(data []byte) error + func (s *WorkflowFeaturesSnapshot) UnmarshalJSON(data []byte) error + func (s WorkflowFeaturesSnapshot) MarshalBSON() ([]byte, error) + func (s WorkflowFeaturesSnapshot) MarshalJSON() ([]byte, error)