Skip to content

Logs Admin ​

Filter the logs table (admin-wide or per-user), aggregate quota by source, and prune historical rows. UI: web/default-pro/src/views/log/Log.vue (shared between admin and user; columns are hidden based on role).

Endpoints ​

EndpointMethodAuthDescription
/api/log/GETAdminPaginated (config.ItemsPerPage)
/api/log/search?keyword=GETAdminKeyword search
/api/log/statGETAdminQuota aggregate (normal + subscription)
/api/log/?target_timestamp=DELETEAdminDelete all rows with created_at < target
/api/log/selfGETUserCaller's own logs
/api/log/self/search?keyword=GETUserCaller's own keyword search
/api/log/self/statGETUserCaller's own quota aggregate

Implementation: controller/log.go.

Common Filter ​

ParamTypeNotes
pintPage index (0-based)
typeintLogTypeTopup=1 / Consume=2 / Manage=3 / System=4 / Test=5
start_timestampint64unix seconds (inclusive); 0 = no lower bound
end_timestampint64unix seconds (inclusive); 0 = no upper bound
usernamestringexact match (admin endpoints)
token_namestringfuzzy match
model_namestringfuzzy match
channelintchannel_id (admin endpoints)

Only LogTypeConsume rows contribute to billed quota; other types are audit only.

Aggregate — /api/log/stat ​

json
{
  "quota": 1234567,
  "normal_quota": 1000000,
  "subscription_quota": 234567
}
  • quota — total sum(quota) over the window.
  • normal_quota — sum where billing_source=0.
  • subscription_quota — sum where billing_source=1.

Implemented in model/log.go::SumUsedQuota and SumUsedQuotaByBillingSource.

Prune — DELETE ​

DELETE /api/log/?target_timestamp=<unix-seconds> removes all rows with created_at < target_timestamp. Returns { data: <affected_rows> }. target_timestamp=0 is rejected. Pair with the date-picker UI in Operation Setting for an interactive prune.

Log Types ​

TypeMeaningCounts toward quota?
LogTypeTopup=1Top-up / redemption / admin manual grantNo
LogTypeConsume=2API call consumptionYes
LogTypeManage=3Admin actions (delete/disable/quota adjustment/grant subscription)No
LogTypeSystem=4System (new-user bonus, invite bonus, …)No
LogTypeTest=5Channel tests (POST /api/channel/test)No

Frontend Guide ​

  • Welcome bar + a type select (all / topup / consume / manage / system / test).
  • Search bar:
    • Regular users: keyword, token_name, model_name, start/end timestamp.
    • Admins: + username, channel id.
  • The Statistics button toggles the quota / normal_quota / subscription_quota summary card.
  • Row columns: time (click to copy request_id) / channel (admin) / source chip (subscription blue / quota grey) / plan / type / model / user (admin) / token name. For non-test rows: Prompt / Completion / Quota. Detail column shows content, elapsed_time (ms; coloured by latency bucket), is_stream, system_prompt_reset tags.
  • Pagination [10, 20, 50]; append-on-scroll.
  • Operation Setting (/setting/operation) exposes a Log Pruning action — pick a date → DELETE /api/log/?target_timestamp=....

Implementation Pointers ​

ConcernLocation
Log handlercontroller/log.go
LogStatistic typemodel/log.go
Quota aggregatemodel/log.go::SumUsedQuota / SumUsedQuotaByBillingSource
Deletemodel/log.go::DeleteOldLog
Prune UIweb/default-pro/src/views/setting/OperationSetting.vue
Routesrouter/api.go