Under the hood

Logging examples

Every line the store logs while handling a request is tagged with that request automatically: no wrapper, no passing the request around. Each example below logs one line on the server and shows you what it carried.

Server Component
Logged while this page rendered, from a helper two awaits deep. Reload to get a new trace id.
In your own code
Name the module where you log; names are typed (see LogModules), and each logger is made once and reused. Production writes one JSON object per line; development pretty-prints and hides the ids.
import { log } from "@turbo-starter/logger"

export async function reserveSample(sku: string) {
  await db.insert(reservations).values({ sku })
  log.info("shop-actions", "Reserved a sample", { sku })
  // → also gets traceId, spanId, method, url, route and action
}
Server Action
An exported action in actions.ts. The logger names it, and the url is the page the form was posted from.
Inline Server Action
Declared inside the page with “use server”. It has no exported name, so the logger falls back to its id.
Route Handler
GET /api/examples/logging, called with fetch from this page. Its own request, so a new trace id.