export type SearchLogEvent =
  | { kind: "provider"; provider: string; status: string; keyword?: string; url?: string; count?: number; quotaUsed?: number; quotaLimit?: number; reason?: string };

export function logSearchEvent(event: SearchLogEvent): void {
  const parts = [`search.${event.kind}=${event.provider}`, `status=${event.status}`];
  if (event.keyword) parts.push(`keyword=${event.keyword}`);
  if (event.url) parts.push(`url=${event.url}`);
  if (event.count !== undefined) parts.push(`count=${event.count}`);
  if (event.quotaUsed !== undefined) parts.push(`quota_used=${event.quotaUsed}`);
  if (event.quotaLimit !== undefined) parts.push(`quota_limit=${event.quotaLimit}`);
  if (event.reason) parts.push(`reason=${event.reason}`);
  console.log(parts.join(" "));
}