[{"data":1,"prerenderedAt":2288},["ShallowReactive",2],{"navigation_docs":3,"-core-concepts-lifecycle":238,"-core-concepts-lifecycle-surround":2283},[4,30,110,154,208,224],{"title":5,"path":6,"stem":7,"children":8,"page":29},"Getting Started","\u002Fgetting-started","1.getting-started",[9,14,19,24],{"title":10,"path":11,"stem":12,"icon":13},"Introduction","\u002Fgetting-started\u002Fintroduction","1.getting-started\u002F1.introduction","i-lucide-info",{"title":15,"path":16,"stem":17,"icon":18},"Installation","\u002Fgetting-started\u002Finstallation","1.getting-started\u002F2.installation","i-lucide-download",{"title":20,"path":21,"stem":22,"icon":23},"Quick Start","\u002Fgetting-started\u002Fquick-start","1.getting-started\u002F3.quick-start","i-lucide-zap",{"title":25,"path":26,"stem":27,"icon":28},"Agent Skills","\u002Fgetting-started\u002Fagent-skills","1.getting-started\u002F4.agent-skills","i-lucide-sparkles",false,{"title":31,"path":32,"stem":33,"children":34,"page":29},"Frameworks","\u002Fframeworks","2.frameworks",[35,40,45,50,55,60,65,70,75,80,85,90,95,100,105],{"title":36,"path":37,"stem":38,"icon":39},"Overview","\u002Fframeworks\u002Foverview","2.frameworks\u002F00.overview","i-lucide-layout-grid",{"title":41,"path":42,"stem":43,"icon":44},"Nuxt","\u002Fframeworks\u002Fnuxt","2.frameworks\u002F01.nuxt","i-simple-icons-nuxtdotjs",{"title":46,"path":47,"stem":48,"icon":49},"Next.js","\u002Fframeworks\u002Fnextjs","2.frameworks\u002F02.nextjs","i-simple-icons-nextdotjs",{"title":51,"path":52,"stem":53,"icon":54},"SvelteKit","\u002Fframeworks\u002Fsveltekit","2.frameworks\u002F03.sveltekit","i-simple-icons-svelte",{"title":56,"path":57,"stem":58,"icon":59},"Nitro","\u002Fframeworks\u002Fnitro","2.frameworks\u002F04.nitro","i-custom-nitro",{"title":61,"path":62,"stem":63,"icon":64},"TanStack Start","\u002Fframeworks\u002Ftanstack-start","2.frameworks\u002F05.tanstack-start","i-custom-tanstack",{"title":66,"path":67,"stem":68,"icon":69},"NestJS","\u002Fframeworks\u002Fnestjs","2.frameworks\u002F06.nestjs","i-simple-icons-nestjs",{"title":71,"path":72,"stem":73,"icon":74},"Express","\u002Fframeworks\u002Fexpress","2.frameworks\u002F07.express","i-simple-icons-express",{"title":76,"path":77,"stem":78,"icon":79},"Hono","\u002Fframeworks\u002Fhono","2.frameworks\u002F08.hono","i-simple-icons-hono",{"title":81,"path":82,"stem":83,"icon":84},"Fastify","\u002Fframeworks\u002Ffastify","2.frameworks\u002F09.fastify","i-simple-icons-fastify",{"title":86,"path":87,"stem":88,"icon":89},"Elysia","\u002Fframeworks\u002Felysia","2.frameworks\u002F10.elysia","i-custom-elysia",{"title":91,"path":92,"stem":93,"icon":94},"Cloudflare Workers","\u002Fframeworks\u002Fcloudflare-workers","2.frameworks\u002F11.cloudflare-workers","i-simple-icons-cloudflare",{"title":96,"path":97,"stem":98,"icon":99},"Standalone","\u002Fframeworks\u002Fstandalone","2.frameworks\u002F12.standalone","i-simple-icons-typescript",{"title":101,"path":102,"stem":103,"icon":104},"Astro","\u002Fframeworks\u002Fastro","2.frameworks\u002F13.astro","i-simple-icons-astro",{"title":106,"path":107,"stem":108,"icon":109},"Custom Integration","\u002Fframeworks\u002Fcustom-integration","2.frameworks\u002F14.custom-integration","i-lucide-puzzle",{"title":111,"path":112,"stem":113,"children":114,"page":29},"Core Concepts","\u002Fcore-concepts","3.core-concepts",[115,120,125,130,135,139,144,149],{"title":116,"path":117,"stem":118,"icon":119},"Request Lifecycle","\u002Fcore-concepts\u002Flifecycle","3.core-concepts\u002F0.lifecycle","i-lucide-arrow-right-left",{"title":121,"path":122,"stem":123,"icon":124},"Wide Events","\u002Fcore-concepts\u002Fwide-events","3.core-concepts\u002F1.wide-events","i-lucide-layers",{"title":126,"path":127,"stem":128,"icon":129},"Structured Errors","\u002Fcore-concepts\u002Fstructured-errors","3.core-concepts\u002F2.structured-errors","i-lucide-shield-alert",{"title":131,"path":132,"stem":133,"icon":134},"Best Practices","\u002Fcore-concepts\u002Fbest-practices","3.core-concepts\u002F3.best-practices","i-lucide-shield-check",{"title":136,"path":137,"stem":138,"icon":99},"Typed Fields","\u002Fcore-concepts\u002Ftyped-fields","3.core-concepts\u002F4.typed-fields",{"title":140,"path":141,"stem":142,"icon":143},"Sampling","\u002Fcore-concepts\u002Fsampling","3.core-concepts\u002F5.sampling","i-lucide-filter",{"title":145,"path":146,"stem":147,"icon":148},"Client Logging","\u002Fcore-concepts\u002Fclient-logging","3.core-concepts\u002F6.client-logging","i-lucide-monitor",{"title":150,"path":151,"stem":152,"icon":153},"Configuration","\u002Fcore-concepts\u002Fconfiguration","3.core-concepts\u002F7.configuration","i-lucide-settings",{"title":155,"path":156,"stem":157,"children":158,"page":29},"Adapters","\u002Fadapters","4.adapters",[159,163,168,173,178,183,188,193,198,203],{"title":36,"path":160,"stem":161,"icon":162},"\u002Fadapters\u002Foverview","4.adapters\u002F1.overview","i-custom-plug",{"title":164,"path":165,"stem":166,"icon":167},"Browser","\u002Fadapters\u002Fbrowser","4.adapters\u002F10.browser","i-lucide-globe",{"title":169,"path":170,"stem":171,"icon":172},"Axiom","\u002Fadapters\u002Faxiom","4.adapters\u002F2.axiom","i-custom-axiom",{"title":174,"path":175,"stem":176,"icon":177},"OTLP","\u002Fadapters\u002Fotlp","4.adapters\u002F3.otlp","i-simple-icons-opentelemetry",{"title":179,"path":180,"stem":181,"icon":182},"PostHog","\u002Fadapters\u002Fposthog","4.adapters\u002F4.posthog","i-simple-icons-posthog",{"title":184,"path":185,"stem":186,"icon":187},"Sentry","\u002Fadapters\u002Fsentry","4.adapters\u002F5.sentry","i-simple-icons-sentry",{"title":189,"path":190,"stem":191,"icon":192},"Better Stack","\u002Fadapters\u002Fbetter-stack","4.adapters\u002F6.better-stack","i-simple-icons-betterstack",{"title":194,"path":195,"stem":196,"icon":197},"File System","\u002Fadapters\u002Ffs","4.adapters\u002F7.fs","i-lucide-hard-drive",{"title":199,"path":200,"stem":201,"icon":202},"Custom Adapters","\u002Fadapters\u002Fcustom","4.adapters\u002F8.custom","i-lucide-code",{"title":204,"path":205,"stem":206,"icon":207},"Pipeline","\u002Fadapters\u002Fpipeline","4.adapters\u002F9.pipeline","i-lucide-workflow",{"title":209,"path":210,"stem":211,"children":212,"page":29},"Enrichers","\u002Fenrichers","5.enrichers",[213,216,220],{"title":36,"path":214,"stem":215,"icon":28},"\u002Fenrichers\u002Foverview","5.enrichers\u002F1.overview",{"title":217,"path":218,"stem":219,"icon":109},"Built-in","\u002Fenrichers\u002Fbuilt-in","5.enrichers\u002F2.built-in",{"title":221,"path":222,"stem":223,"icon":202},"Custom","\u002Fenrichers\u002Fcustom","5.enrichers\u002F3.custom",{"title":225,"path":226,"stem":227,"children":228,"page":29},"NuxtHub","\u002Fnuxthub","6.nuxthub",[229,233],{"title":36,"path":230,"stem":231,"icon":232},"\u002Fnuxthub\u002Foverview","6.nuxthub\u002F1.overview","i-lucide-database",{"title":234,"path":235,"stem":236,"icon":237},"Retention","\u002Fnuxthub\u002Fretention","6.nuxthub\u002F2.retention","i-lucide-clock",{"id":239,"title":116,"body":240,"description":2272,"extension":2273,"links":2274,"meta":2279,"navigation":2280,"path":117,"seo":2281,"stem":118,"__hash__":2282},"docs\u002F3.core-concepts\u002F0.lifecycle.md",{"type":241,"value":242,"toc":2253},"minimark",[243,247,559,564,569,580,678,682,689,764,771,775,782,968,975,979,982,1025,1028,1035,1047,1157,1163,1295,1305,1309,1312,1381,1404,1407,1411,1417,1665,1668,1675,1678,1758,1917,1924,1931,1941,2024,2031,2035,2100,2104,2111,2222,2226,2249],[244,245,246],"p",{},"Every request that passes through evlog follows the same pipeline. Understanding this pipeline helps you know exactly when your hooks fire, where context is added, and how events reach your observability platform.",[248,249,254],"pre",{"className":250,"code":251,"language":252,"meta":253,"style":253},"language-mdc shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","   Request In\n       │\n       ▼\n  ┌──────────┐     Route excluded?\n  │  Filter  │────── yes ──▶ skip (no logging)\n  └──────────┘\n       │ no\n       ▼\n  ┌──────────────────┐\n  │  Create Logger   │  requestId, method, path, startTime\n  └──────────────────┘\n       │\n       ▼\n  ┌──────────────────┐\n  │  Handler runs    │  log.set() accumulates context\n  │                  │  log.error() records errors\n  └──────────────────┘\n       │\n       ▼\n  ┌──────────────────┐\n  │  Request ends    │  status + duration computed\n  └──────────────────┘\n       │\n       ▼\n  ┌──────────────────┐\n  │  Tail Sampling   │  evlog:emit:keep hook\n  │  (keep?)         │  force-keep based on outcome\n  └──────────────────┘\n       │\n       ▼\n  ┌──────────────────┐\n  │  Head Sampling   │  random % per level\n  │  (sample?)       │  skipped if tail said \"keep\"\n  └──────────────────┘\n       │ sampled out? ──▶ discard (no output)\n       │\n       ▼\n  ┌──────────────────┐\n  │  Emit            │  WideEvent built + console output\n  └──────────────────┘\n       │\n       ▼\n  ┌──────────────────┐\n  │  Enrich          │  evlog:enrich hook\n  │                  │  user-agent, geo, trace, custom\n  └──────────────────┘\n       │\n       ▼\n  ┌──────────────────┐\n  │  Drain           │  evlog:drain hook\n  │                  │  Axiom, OTLP, Sentry, custom\n  └──────────────────┘\n       │\n       ▼\n   Done\n","mdc","",[255,256,257,266,272,278,284,290,296,302,307,313,319,325,330,335,340,346,352,357,362,367,372,378,383,388,393,398,404,410,415,420,425,430,436,442,447,453,458,463,468,474,479,484,489,494,500,506,511,516,521,526,532,538,543,548,553],"code",{"__ignoreMap":253},[258,259,262],"span",{"class":260,"line":261},"line",1,[258,263,265],{"class":264},"sTEyZ","   Request In\n",[258,267,269],{"class":260,"line":268},2,[258,270,271],{"class":264},"       │\n",[258,273,275],{"class":260,"line":274},3,[258,276,277],{"class":264},"       ▼\n",[258,279,281],{"class":260,"line":280},4,[258,282,283],{"class":264},"  ┌──────────┐     Route excluded?\n",[258,285,287],{"class":260,"line":286},5,[258,288,289],{"class":264},"  │  Filter  │────── yes ──▶ skip (no logging)\n",[258,291,293],{"class":260,"line":292},6,[258,294,295],{"class":264},"  └──────────┘\n",[258,297,299],{"class":260,"line":298},7,[258,300,301],{"class":264},"       │ no\n",[258,303,305],{"class":260,"line":304},8,[258,306,277],{"class":264},[258,308,310],{"class":260,"line":309},9,[258,311,312],{"class":264},"  ┌──────────────────┐\n",[258,314,316],{"class":260,"line":315},10,[258,317,318],{"class":264},"  │  Create Logger   │  requestId, method, path, startTime\n",[258,320,322],{"class":260,"line":321},11,[258,323,324],{"class":264},"  └──────────────────┘\n",[258,326,328],{"class":260,"line":327},12,[258,329,271],{"class":264},[258,331,333],{"class":260,"line":332},13,[258,334,277],{"class":264},[258,336,338],{"class":260,"line":337},14,[258,339,312],{"class":264},[258,341,343],{"class":260,"line":342},15,[258,344,345],{"class":264},"  │  Handler runs    │  log.set() accumulates context\n",[258,347,349],{"class":260,"line":348},16,[258,350,351],{"class":264},"  │                  │  log.error() records errors\n",[258,353,355],{"class":260,"line":354},17,[258,356,324],{"class":264},[258,358,360],{"class":260,"line":359},18,[258,361,271],{"class":264},[258,363,365],{"class":260,"line":364},19,[258,366,277],{"class":264},[258,368,370],{"class":260,"line":369},20,[258,371,312],{"class":264},[258,373,375],{"class":260,"line":374},21,[258,376,377],{"class":264},"  │  Request ends    │  status + duration computed\n",[258,379,381],{"class":260,"line":380},22,[258,382,324],{"class":264},[258,384,386],{"class":260,"line":385},23,[258,387,271],{"class":264},[258,389,391],{"class":260,"line":390},24,[258,392,277],{"class":264},[258,394,396],{"class":260,"line":395},25,[258,397,312],{"class":264},[258,399,401],{"class":260,"line":400},26,[258,402,403],{"class":264},"  │  Tail Sampling   │  evlog:emit:keep hook\n",[258,405,407],{"class":260,"line":406},27,[258,408,409],{"class":264},"  │  (keep?)         │  force-keep based on outcome\n",[258,411,413],{"class":260,"line":412},28,[258,414,324],{"class":264},[258,416,418],{"class":260,"line":417},29,[258,419,271],{"class":264},[258,421,423],{"class":260,"line":422},30,[258,424,277],{"class":264},[258,426,428],{"class":260,"line":427},31,[258,429,312],{"class":264},[258,431,433],{"class":260,"line":432},32,[258,434,435],{"class":264},"  │  Head Sampling   │  random % per level\n",[258,437,439],{"class":260,"line":438},33,[258,440,441],{"class":264},"  │  (sample?)       │  skipped if tail said \"keep\"\n",[258,443,445],{"class":260,"line":444},34,[258,446,324],{"class":264},[258,448,450],{"class":260,"line":449},35,[258,451,452],{"class":264},"       │ sampled out? ──▶ discard (no output)\n",[258,454,456],{"class":260,"line":455},36,[258,457,271],{"class":264},[258,459,461],{"class":260,"line":460},37,[258,462,277],{"class":264},[258,464,466],{"class":260,"line":465},38,[258,467,312],{"class":264},[258,469,471],{"class":260,"line":470},39,[258,472,473],{"class":264},"  │  Emit            │  WideEvent built + console output\n",[258,475,477],{"class":260,"line":476},40,[258,478,324],{"class":264},[258,480,482],{"class":260,"line":481},41,[258,483,271],{"class":264},[258,485,487],{"class":260,"line":486},42,[258,488,277],{"class":264},[258,490,492],{"class":260,"line":491},43,[258,493,312],{"class":264},[258,495,497],{"class":260,"line":496},44,[258,498,499],{"class":264},"  │  Enrich          │  evlog:enrich hook\n",[258,501,503],{"class":260,"line":502},45,[258,504,505],{"class":264},"  │                  │  user-agent, geo, trace, custom\n",[258,507,509],{"class":260,"line":508},46,[258,510,324],{"class":264},[258,512,514],{"class":260,"line":513},47,[258,515,271],{"class":264},[258,517,519],{"class":260,"line":518},48,[258,520,277],{"class":264},[258,522,524],{"class":260,"line":523},49,[258,525,312],{"class":264},[258,527,529],{"class":260,"line":528},50,[258,530,531],{"class":264},"  │  Drain           │  evlog:drain hook\n",[258,533,535],{"class":260,"line":534},51,[258,536,537],{"class":264},"  │                  │  Axiom, OTLP, Sentry, custom\n",[258,539,541],{"class":260,"line":540},52,[258,542,324],{"class":264},[258,544,546],{"class":260,"line":545},53,[258,547,271],{"class":264},[258,549,551],{"class":260,"line":550},54,[258,552,277],{"class":264},[258,554,556],{"class":260,"line":555},55,[258,557,558],{"class":264},"   Done\n",[560,561,563],"h2",{"id":562},"step-by-step","Step by Step",[565,566,568],"h3",{"id":567},"_1-route-filtering","1. Route Filtering",[244,570,571,572,575,576,579],{},"When a request arrives, evlog checks whether the path matches the configured ",[255,573,574],{},"include"," \u002F ",[255,577,578],{},"exclude"," patterns. If the route is excluded, no logger is created and the request proceeds without any logging overhead.",[248,581,586],{"className":582,"code":583,"filename":584,"language":585,"meta":253,"style":253},"language-typescript shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","export default defineNuxtConfig({\n  modules: ['evlog\u002Fnuxt'],\n  evlog: {\n    include: ['\u002Fapi\u002F**'],\n  },\n})\n","nuxt.config.ts","typescript",[255,587,588,608,635,645,665,670],{"__ignoreMap":253},[258,589,590,594,597,601,604],{"class":260,"line":261},[258,591,593],{"class":592},"s7zQu","export",[258,595,596],{"class":592}," default",[258,598,600],{"class":599},"s2Zo4"," defineNuxtConfig",[258,602,603],{"class":264},"(",[258,605,607],{"class":606},"sMK4o","{\n",[258,609,610,614,617,620,623,627,629,632],{"class":260,"line":268},[258,611,613],{"class":612},"swJcz","  modules",[258,615,616],{"class":606},":",[258,618,619],{"class":264}," [",[258,621,622],{"class":606},"'",[258,624,626],{"class":625},"sfazB","evlog\u002Fnuxt",[258,628,622],{"class":606},[258,630,631],{"class":264},"]",[258,633,634],{"class":606},",\n",[258,636,637,640,642],{"class":260,"line":274},[258,638,639],{"class":612},"  evlog",[258,641,616],{"class":606},[258,643,644],{"class":606}," {\n",[258,646,647,650,652,654,656,659,661,663],{"class":260,"line":280},[258,648,649],{"class":612},"    include",[258,651,616],{"class":606},[258,653,619],{"class":264},[258,655,622],{"class":606},[258,657,658],{"class":625},"\u002Fapi\u002F**",[258,660,622],{"class":606},[258,662,631],{"class":264},[258,664,634],{"class":606},[258,666,667],{"class":260,"line":286},[258,668,669],{"class":606},"  },\n",[258,671,672,675],{"class":260,"line":292},[258,673,674],{"class":606},"}",[258,676,677],{"class":264},")\n",[565,679,681],{"id":680},"_2-logger-creation","2. Logger Creation",[244,683,684,685,688],{},"For matched routes, evlog creates a ",[255,686,687],{},"RequestLogger"," and attaches it to the request context. The logger is pre-populated with:",[690,691,692,705],"table",{},[693,694,695],"thead",{},[696,697,698,702],"tr",{},[699,700,701],"th",{},"Field",[699,703,704],{},"Source",[706,707,708,727,737,751],"tbody",{},[696,709,710,716],{},[711,712,713],"td",{},[255,714,715],{},"method",[711,717,718,719,722,723,726],{},"HTTP method (",[255,720,721],{},"GET",", ",[255,724,725],{},"POST",", ...)",[696,728,729,734],{},[711,730,731],{},[255,732,733],{},"path",[711,735,736],{},"Request path",[696,738,739,744],{},[711,740,741],{},[255,742,743],{},"requestId",[711,745,746,747,750],{},"Auto-generated UUID (or ",[255,748,749],{},"cf-ray"," on Cloudflare)",[696,752,753,758],{},[711,754,755],{},[255,756,757],{},"startTime",[711,759,760,763],{},[255,761,762],{},"Date.now()"," for duration calculation",[244,765,766,767,770],{},"The logger is stored on the event context so it's accessible via ",[255,768,769],{},"useLogger(event)",".",[565,772,774],{"id":773},"_3-context-accumulation","3. Context Accumulation",[244,776,777,778,781],{},"During the handler, you call ",[255,779,780],{},"log.set()"," to attach context. Each call deep-merges into the existing context, so you can call it as many times as needed:",[248,783,786],{"className":582,"code":784,"filename":785,"language":585,"meta":253,"style":253},"const log = useLogger(event)\n\nconst user = await getUser(event)\nlog.set({ user: { id: user.id, plan: user.plan } })\n\nconst cart = await getCart(user.id)\nlog.set({ cart: { items: cart.items.length, total: cart.total } })\n","server\u002Fapi\u002Fcheckout.post.ts",[255,787,788,806,812,829,886,890,912],{"__ignoreMap":253},[258,789,790,794,797,800,803],{"class":260,"line":261},[258,791,793],{"class":792},"spNyl","const",[258,795,796],{"class":264}," log ",[258,798,799],{"class":606},"=",[258,801,802],{"class":599}," useLogger",[258,804,805],{"class":264},"(event)\n",[258,807,808],{"class":260,"line":268},[258,809,811],{"emptyLinePlaceholder":810},true,"\n",[258,813,814,816,819,821,824,827],{"class":260,"line":274},[258,815,793],{"class":792},[258,817,818],{"class":264}," user ",[258,820,799],{"class":606},[258,822,823],{"class":592}," await",[258,825,826],{"class":599}," getUser",[258,828,805],{"class":264},[258,830,831,834,836,839,841,844,847,849,852,855,857,859,861,864,867,870,872,874,876,879,881,884],{"class":260,"line":280},[258,832,833],{"class":264},"log",[258,835,770],{"class":606},[258,837,838],{"class":599},"set",[258,840,603],{"class":264},[258,842,843],{"class":606},"{",[258,845,846],{"class":612}," user",[258,848,616],{"class":606},[258,850,851],{"class":606}," {",[258,853,854],{"class":612}," id",[258,856,616],{"class":606},[258,858,846],{"class":264},[258,860,770],{"class":606},[258,862,863],{"class":264},"id",[258,865,866],{"class":606},",",[258,868,869],{"class":612}," plan",[258,871,616],{"class":606},[258,873,846],{"class":264},[258,875,770],{"class":606},[258,877,878],{"class":264},"plan ",[258,880,674],{"class":606},[258,882,883],{"class":606}," }",[258,885,677],{"class":264},[258,887,888],{"class":260,"line":286},[258,889,811],{"emptyLinePlaceholder":810},[258,891,892,894,897,899,901,904,907,909],{"class":260,"line":292},[258,893,793],{"class":792},[258,895,896],{"class":264}," cart ",[258,898,799],{"class":606},[258,900,823],{"class":592},[258,902,903],{"class":599}," getCart",[258,905,906],{"class":264},"(user",[258,908,770],{"class":606},[258,910,911],{"class":264},"id)\n",[258,913,914,916,918,920,922,924,927,929,931,934,936,938,940,943,945,948,950,953,955,957,959,962,964,966],{"class":260,"line":298},[258,915,833],{"class":264},[258,917,770],{"class":606},[258,919,838],{"class":599},[258,921,603],{"class":264},[258,923,843],{"class":606},[258,925,926],{"class":612}," cart",[258,928,616],{"class":606},[258,930,851],{"class":606},[258,932,933],{"class":612}," items",[258,935,616],{"class":606},[258,937,926],{"class":264},[258,939,770],{"class":606},[258,941,942],{"class":264},"items",[258,944,770],{"class":606},[258,946,947],{"class":264},"length",[258,949,866],{"class":606},[258,951,952],{"class":612}," total",[258,954,616],{"class":606},[258,956,926],{"class":264},[258,958,770],{"class":606},[258,960,961],{"class":264},"total ",[258,963,674],{"class":606},[258,965,883],{"class":606},[258,967,677],{"class":264},[244,969,970,971,974],{},"If an error is thrown, evlog's ",[255,972,973],{},"error"," hook captures it automatically and records it on the logger with the status code.",[565,976,978],{"id":977},"_4-request-end","4. Request End",[244,980,981],{},"When the response is sent (or an error is thrown), evlog computes:",[983,984,985,1000,1009],"ul",{},[986,987,988,992,993,575,996,999],"li",{},[989,990,991],"strong",{},"Status code"," from the response (or from the error's ",[255,994,995],{},"status",[255,997,998],{},"statusCode",")",[986,1001,1002,1005,1006],{},[989,1003,1004],{},"Duration"," from ",[255,1007,1008],{},"Date.now() - startTime",[986,1010,1011,1014,1015,1017,1018,1021,1022],{},[989,1012,1013],{},"Level"," - ",[255,1016,973],{}," if an error was recorded, ",[255,1019,1020],{},"warn"," if status >= 400, otherwise ",[255,1023,1024],{},"info",[244,1026,1027],{},"If an error triggered the emit, the request is marked as already emitted to prevent double-emission in the response hook.",[565,1029,1031,1032,999],{"id":1030},"_5-tail-sampling-evlogemitkeep","5. Tail Sampling (",[255,1033,1034],{},"evlog:emit:keep",[244,1036,1037,1038,1041,1042,1046],{},"Before the event is sampled, evlog evaluates ",[989,1039,1040],{},"tail sampling"," rules. These run ",[1043,1044,1045],"em",{},"after"," the request completes, so they can inspect the outcome:",[248,1048,1050],{"className":582,"code":1049,"filename":584,"language":585,"meta":253,"style":253},"evlog: {\n  sampling: {\n    keep: [\n      { duration: 1000 },          \u002F\u002F slow requests\n      { status: 400 },             \u002F\u002F client\u002Fserver errors\n      { path: '\u002Fapi\u002Fcritical\u002F**' }, \u002F\u002F critical paths\n    ],\n  },\n}\n",[255,1051,1052,1062,1071,1081,1102,1119,1141,1148,1152],{"__ignoreMap":253},[258,1053,1054,1058,1060],{"class":260,"line":261},[258,1055,1057],{"class":1056},"sBMFI","evlog",[258,1059,616],{"class":606},[258,1061,644],{"class":606},[258,1063,1064,1067,1069],{"class":260,"line":268},[258,1065,1066],{"class":1056},"  sampling",[258,1068,616],{"class":606},[258,1070,644],{"class":606},[258,1072,1073,1076,1078],{"class":260,"line":274},[258,1074,1075],{"class":1056},"    keep",[258,1077,616],{"class":606},[258,1079,1080],{"class":612}," [\n",[258,1082,1083,1086,1089,1091,1095,1098],{"class":260,"line":280},[258,1084,1085],{"class":606},"      {",[258,1087,1088],{"class":612}," duration",[258,1090,616],{"class":606},[258,1092,1094],{"class":1093},"sbssI"," 1000",[258,1096,1097],{"class":606}," },",[258,1099,1101],{"class":1100},"sHwdD","          \u002F\u002F slow requests\n",[258,1103,1104,1106,1109,1111,1114,1116],{"class":260,"line":286},[258,1105,1085],{"class":606},[258,1107,1108],{"class":612}," status",[258,1110,616],{"class":606},[258,1112,1113],{"class":1093}," 400",[258,1115,1097],{"class":606},[258,1117,1118],{"class":1100},"             \u002F\u002F client\u002Fserver errors\n",[258,1120,1121,1123,1126,1128,1131,1134,1136,1138],{"class":260,"line":292},[258,1122,1085],{"class":606},[258,1124,1125],{"class":612}," path",[258,1127,616],{"class":606},[258,1129,1130],{"class":606}," '",[258,1132,1133],{"class":625},"\u002Fapi\u002Fcritical\u002F**",[258,1135,622],{"class":606},[258,1137,1097],{"class":606},[258,1139,1140],{"class":1100}," \u002F\u002F critical paths\n",[258,1142,1143,1146],{"class":260,"line":298},[258,1144,1145],{"class":612},"    ]",[258,1147,634],{"class":606},[258,1149,1150],{"class":260,"line":304},[258,1151,669],{"class":606},[258,1153,1154],{"class":260,"line":309},[258,1155,1156],{"class":606},"}\n",[244,1158,1159,1160,1162],{},"The ",[255,1161,1034],{}," hook also fires, letting you force-keep based on custom business logic:",[248,1164,1167],{"className":582,"code":1165,"filename":1166,"language":585,"meta":253,"style":253},"export default defineNitroPlugin((nitroApp) => {\n  nitroApp.hooks.hook('evlog:emit:keep', (ctx) => {\n    if (ctx.context.user?.premium) {\n      ctx.shouldKeep = true\n    }\n  })\n})\n","server\u002Fplugins\u002Fevlog-custom.ts",[255,1168,1169,1193,1230,1260,1277,1282,1289],{"__ignoreMap":253},[258,1170,1171,1173,1175,1178,1180,1182,1186,1188,1191],{"class":260,"line":261},[258,1172,593],{"class":592},[258,1174,596],{"class":592},[258,1176,1177],{"class":599}," defineNitroPlugin",[258,1179,603],{"class":264},[258,1181,603],{"class":606},[258,1183,1185],{"class":1184},"sHdIc","nitroApp",[258,1187,999],{"class":606},[258,1189,1190],{"class":792}," =>",[258,1192,644],{"class":606},[258,1194,1195,1198,1200,1203,1205,1208,1210,1212,1214,1216,1218,1221,1224,1226,1228],{"class":260,"line":268},[258,1196,1197],{"class":264},"  nitroApp",[258,1199,770],{"class":606},[258,1201,1202],{"class":264},"hooks",[258,1204,770],{"class":606},[258,1206,1207],{"class":599},"hook",[258,1209,603],{"class":612},[258,1211,622],{"class":606},[258,1213,1034],{"class":625},[258,1215,622],{"class":606},[258,1217,866],{"class":606},[258,1219,1220],{"class":606}," (",[258,1222,1223],{"class":1184},"ctx",[258,1225,999],{"class":606},[258,1227,1190],{"class":792},[258,1229,644],{"class":606},[258,1231,1232,1235,1237,1239,1241,1244,1246,1249,1252,1255,1258],{"class":260,"line":274},[258,1233,1234],{"class":592},"    if",[258,1236,1220],{"class":612},[258,1238,1223],{"class":264},[258,1240,770],{"class":606},[258,1242,1243],{"class":264},"context",[258,1245,770],{"class":606},[258,1247,1248],{"class":264},"user",[258,1250,1251],{"class":606},"?.",[258,1253,1254],{"class":264},"premium",[258,1256,1257],{"class":612},") ",[258,1259,607],{"class":606},[258,1261,1262,1265,1267,1270,1273],{"class":260,"line":280},[258,1263,1264],{"class":264},"      ctx",[258,1266,770],{"class":606},[258,1268,1269],{"class":264},"shouldKeep",[258,1271,1272],{"class":606}," =",[258,1274,1276],{"class":1275},"sfNiH"," true\n",[258,1278,1279],{"class":260,"line":286},[258,1280,1281],{"class":606},"    }\n",[258,1283,1284,1287],{"class":260,"line":292},[258,1285,1286],{"class":606},"  }",[258,1288,677],{"class":612},[258,1290,1291,1293],{"class":260,"line":298},[258,1292,674],{"class":606},[258,1294,677],{"class":264},[244,1296,1297,1298,1301,1302,770],{},"If any rule or hook sets ",[255,1299,1300],{},"shouldKeep = true",", the event ",[989,1303,1304],{},"bypasses head sampling entirely",[565,1306,1308],{"id":1307},"_6-head-sampling","6. Head Sampling",[244,1310,1311],{},"If the event wasn't force-kept by tail sampling, head sampling applies. This is a random coin flip per log level:",[248,1313,1315],{"className":582,"code":1314,"filename":584,"language":585,"meta":253,"style":253},"evlog: {\n  sampling: {\n    rates: { info: 10, warn: 50, debug: 0 },\n  },\n}\n",[255,1316,1317,1325,1333,1373,1377],{"__ignoreMap":253},[258,1318,1319,1321,1323],{"class":260,"line":261},[258,1320,1057],{"class":1056},[258,1322,616],{"class":606},[258,1324,644],{"class":606},[258,1326,1327,1329,1331],{"class":260,"line":268},[258,1328,1066],{"class":1056},[258,1330,616],{"class":606},[258,1332,644],{"class":606},[258,1334,1335,1338,1340,1342,1345,1347,1350,1352,1355,1357,1360,1362,1365,1367,1370],{"class":260,"line":274},[258,1336,1337],{"class":1056},"    rates",[258,1339,616],{"class":606},[258,1341,851],{"class":606},[258,1343,1344],{"class":1056}," info",[258,1346,616],{"class":606},[258,1348,1349],{"class":1093}," 10",[258,1351,866],{"class":606},[258,1353,1354],{"class":1056}," warn",[258,1356,616],{"class":606},[258,1358,1359],{"class":1093}," 50",[258,1361,866],{"class":606},[258,1363,1364],{"class":1056}," debug",[258,1366,616],{"class":606},[258,1368,1369],{"class":1093}," 0",[258,1371,1372],{"class":606}," },\n",[258,1374,1375],{"class":260,"line":280},[258,1376,669],{"class":606},[258,1378,1379],{"class":260,"line":286},[258,1380,1156],{"class":606},[983,1382,1383,1389,1395],{},[986,1384,1385,1388],{},[255,1386,1387],{},"info: 10"," - keep 10% of info-level events",[986,1390,1391,1394],{},[255,1392,1393],{},"warn: 50"," - keep 50% of warnings",[986,1396,1397,1399,1400,1403],{},[255,1398,973],{}," defaults to ",[989,1401,1402],{},"100%"," (never sampled out)",[244,1405,1406],{},"If the event is sampled out, processing stops entirely: no console output, no enrichment, no drain.",[565,1408,1410],{"id":1409},"_7-emit","7. Emit",[244,1412,1159,1413,1416],{},[255,1414,1415],{},"WideEvent"," object is built from the accumulated context:",[248,1418,1422],{"className":1419,"code":1420,"language":1421,"meta":253,"style":253},"language-json shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","{\n  \"timestamp\": \"2025-01-15T10:30:00.000Z\",\n  \"level\": \"info\",\n  \"service\": \"my-app\",\n  \"method\": \"POST\",\n  \"path\": \"\u002Fapi\u002Fcheckout\",\n  \"requestId\": \"abc-123\",\n  \"duration\": 234,\n  \"status\": 200,\n  \"user\": { \"id\": 1, \"plan\": \"pro\" },\n  \"cart\": { \"items\": 3, \"total\": 9999 }\n}\n","json",[255,1423,1424,1428,1451,1470,1490,1508,1527,1546,1562,1577,1620,1661],{"__ignoreMap":253},[258,1425,1426],{"class":260,"line":261},[258,1427,607],{"class":606},[258,1429,1430,1433,1436,1439,1441,1444,1447,1449],{"class":260,"line":268},[258,1431,1432],{"class":606},"  \"",[258,1434,1435],{"class":792},"timestamp",[258,1437,1438],{"class":606},"\"",[258,1440,616],{"class":606},[258,1442,1443],{"class":606}," \"",[258,1445,1446],{"class":625},"2025-01-15T10:30:00.000Z",[258,1448,1438],{"class":606},[258,1450,634],{"class":606},[258,1452,1453,1455,1458,1460,1462,1464,1466,1468],{"class":260,"line":274},[258,1454,1432],{"class":606},[258,1456,1457],{"class":792},"level",[258,1459,1438],{"class":606},[258,1461,616],{"class":606},[258,1463,1443],{"class":606},[258,1465,1024],{"class":625},[258,1467,1438],{"class":606},[258,1469,634],{"class":606},[258,1471,1472,1474,1477,1479,1481,1483,1486,1488],{"class":260,"line":280},[258,1473,1432],{"class":606},[258,1475,1476],{"class":792},"service",[258,1478,1438],{"class":606},[258,1480,616],{"class":606},[258,1482,1443],{"class":606},[258,1484,1485],{"class":625},"my-app",[258,1487,1438],{"class":606},[258,1489,634],{"class":606},[258,1491,1492,1494,1496,1498,1500,1502,1504,1506],{"class":260,"line":286},[258,1493,1432],{"class":606},[258,1495,715],{"class":792},[258,1497,1438],{"class":606},[258,1499,616],{"class":606},[258,1501,1443],{"class":606},[258,1503,725],{"class":625},[258,1505,1438],{"class":606},[258,1507,634],{"class":606},[258,1509,1510,1512,1514,1516,1518,1520,1523,1525],{"class":260,"line":292},[258,1511,1432],{"class":606},[258,1513,733],{"class":792},[258,1515,1438],{"class":606},[258,1517,616],{"class":606},[258,1519,1443],{"class":606},[258,1521,1522],{"class":625},"\u002Fapi\u002Fcheckout",[258,1524,1438],{"class":606},[258,1526,634],{"class":606},[258,1528,1529,1531,1533,1535,1537,1539,1542,1544],{"class":260,"line":298},[258,1530,1432],{"class":606},[258,1532,743],{"class":792},[258,1534,1438],{"class":606},[258,1536,616],{"class":606},[258,1538,1443],{"class":606},[258,1540,1541],{"class":625},"abc-123",[258,1543,1438],{"class":606},[258,1545,634],{"class":606},[258,1547,1548,1550,1553,1555,1557,1560],{"class":260,"line":304},[258,1549,1432],{"class":606},[258,1551,1552],{"class":792},"duration",[258,1554,1438],{"class":606},[258,1556,616],{"class":606},[258,1558,1559],{"class":1093}," 234",[258,1561,634],{"class":606},[258,1563,1564,1566,1568,1570,1572,1575],{"class":260,"line":309},[258,1565,1432],{"class":606},[258,1567,995],{"class":792},[258,1569,1438],{"class":606},[258,1571,616],{"class":606},[258,1573,1574],{"class":1093}," 200",[258,1576,634],{"class":606},[258,1578,1579,1581,1583,1585,1587,1589,1591,1593,1595,1597,1600,1602,1604,1607,1609,1611,1613,1616,1618],{"class":260,"line":315},[258,1580,1432],{"class":606},[258,1582,1248],{"class":792},[258,1584,1438],{"class":606},[258,1586,616],{"class":606},[258,1588,851],{"class":606},[258,1590,1443],{"class":606},[258,1592,863],{"class":1056},[258,1594,1438],{"class":606},[258,1596,616],{"class":606},[258,1598,1599],{"class":1093}," 1",[258,1601,866],{"class":606},[258,1603,1443],{"class":606},[258,1605,1606],{"class":1056},"plan",[258,1608,1438],{"class":606},[258,1610,616],{"class":606},[258,1612,1443],{"class":606},[258,1614,1615],{"class":625},"pro",[258,1617,1438],{"class":606},[258,1619,1372],{"class":606},[258,1621,1622,1624,1627,1629,1631,1633,1635,1637,1639,1641,1644,1646,1648,1651,1653,1655,1658],{"class":260,"line":321},[258,1623,1432],{"class":606},[258,1625,1626],{"class":792},"cart",[258,1628,1438],{"class":606},[258,1630,616],{"class":606},[258,1632,851],{"class":606},[258,1634,1443],{"class":606},[258,1636,942],{"class":1056},[258,1638,1438],{"class":606},[258,1640,616],{"class":606},[258,1642,1643],{"class":1093}," 3",[258,1645,866],{"class":606},[258,1647,1443],{"class":606},[258,1649,1650],{"class":1056},"total",[258,1652,1438],{"class":606},[258,1654,616],{"class":606},[258,1656,1657],{"class":1093}," 9999",[258,1659,1660],{"class":606}," }\n",[258,1662,1663],{"class":260,"line":327},[258,1664,1156],{"class":606},[244,1666,1667],{},"The event is printed to the console, pretty-formatted in development and as JSON in production.",[565,1669,1671,1672,999],{"id":1670},"_8-enrich-evlogenrich","8. Enrich (",[255,1673,1674],{},"evlog:enrich",[244,1676,1677],{},"After emission, enrichers add derived context to the event. Built-in enrichers extract data from request headers:",[690,1679,1680,1692],{},[693,1681,1682],{},[696,1683,1684,1687,1690],{},[699,1685,1686],{},"Enricher",[699,1688,1689],{},"Adds",[699,1691,704],{},[706,1693,1694,1711,1725,1742],{},[696,1695,1696,1699,1705],{},[711,1697,1698],{},"User Agent",[711,1700,1701,1704],{},[255,1702,1703],{},"userAgent"," (browser, OS, device)",[711,1706,1707,1710],{},[255,1708,1709],{},"User-Agent"," header",[696,1712,1713,1716,1722],{},[711,1714,1715],{},"Geo",[711,1717,1718,1721],{},[255,1719,1720],{},"geo"," (country, region, city)",[711,1723,1724],{},"Platform headers (Vercel, Cloudflare)",[696,1726,1727,1730,1736],{},[711,1728,1729],{},"Request Size",[711,1731,1732,1735],{},[255,1733,1734],{},"requestSize"," (request\u002Fresponse bytes)",[711,1737,1738,1741],{},[255,1739,1740],{},"Content-Length"," headers",[696,1743,1744,1747,1753],{},[711,1745,1746],{},"Trace Context",[711,1748,1749,1752],{},[255,1750,1751],{},"traceContext"," (traceId, spanId)",[711,1754,1755,1710],{},[255,1756,1757],{},"traceparent",[248,1759,1762],{"className":582,"code":1760,"filename":1761,"language":585,"meta":253,"style":253},"import { createUserAgentEnricher, createGeoEnricher } from 'evlog\u002Fenrichers'\n\nexport default defineNitroPlugin((nitroApp) => {\n  const enrichers = [createUserAgentEnricher(), createGeoEnricher()]\n\n  nitroApp.hooks.hook('evlog:enrich', (ctx) => {\n    for (const enricher of enrichers) enricher(ctx)\n  })\n})\n","server\u002Fplugins\u002Fevlog-enrich.ts",[255,1763,1764,1792,1796,1816,1841,1845,1877,1905,1911],{"__ignoreMap":253},[258,1765,1766,1769,1771,1774,1776,1779,1781,1784,1786,1789],{"class":260,"line":261},[258,1767,1768],{"class":592},"import",[258,1770,851],{"class":606},[258,1772,1773],{"class":264}," createUserAgentEnricher",[258,1775,866],{"class":606},[258,1777,1778],{"class":264}," createGeoEnricher",[258,1780,883],{"class":606},[258,1782,1783],{"class":592}," from",[258,1785,1130],{"class":606},[258,1787,1788],{"class":625},"evlog\u002Fenrichers",[258,1790,1791],{"class":606},"'\n",[258,1793,1794],{"class":260,"line":268},[258,1795,811],{"emptyLinePlaceholder":810},[258,1797,1798,1800,1802,1804,1806,1808,1810,1812,1814],{"class":260,"line":274},[258,1799,593],{"class":592},[258,1801,596],{"class":592},[258,1803,1177],{"class":599},[258,1805,603],{"class":264},[258,1807,603],{"class":606},[258,1809,1185],{"class":1184},[258,1811,999],{"class":606},[258,1813,1190],{"class":792},[258,1815,644],{"class":606},[258,1817,1818,1821,1824,1826,1828,1831,1834,1836,1838],{"class":260,"line":280},[258,1819,1820],{"class":792},"  const",[258,1822,1823],{"class":264}," enrichers",[258,1825,1272],{"class":606},[258,1827,619],{"class":612},[258,1829,1830],{"class":599},"createUserAgentEnricher",[258,1832,1833],{"class":612},"()",[258,1835,866],{"class":606},[258,1837,1778],{"class":599},[258,1839,1840],{"class":612},"()]\n",[258,1842,1843],{"class":260,"line":286},[258,1844,811],{"emptyLinePlaceholder":810},[258,1846,1847,1849,1851,1853,1855,1857,1859,1861,1863,1865,1867,1869,1871,1873,1875],{"class":260,"line":292},[258,1848,1197],{"class":264},[258,1850,770],{"class":606},[258,1852,1202],{"class":264},[258,1854,770],{"class":606},[258,1856,1207],{"class":599},[258,1858,603],{"class":612},[258,1860,622],{"class":606},[258,1862,1674],{"class":625},[258,1864,622],{"class":606},[258,1866,866],{"class":606},[258,1868,1220],{"class":606},[258,1870,1223],{"class":1184},[258,1872,999],{"class":606},[258,1874,1190],{"class":792},[258,1876,644],{"class":606},[258,1878,1879,1882,1884,1886,1889,1892,1894,1896,1899,1901,1903],{"class":260,"line":298},[258,1880,1881],{"class":592},"    for",[258,1883,1220],{"class":612},[258,1885,793],{"class":792},[258,1887,1888],{"class":264}," enricher",[258,1890,1891],{"class":606}," of",[258,1893,1823],{"class":264},[258,1895,1257],{"class":612},[258,1897,1898],{"class":599},"enricher",[258,1900,603],{"class":612},[258,1902,1223],{"class":264},[258,1904,677],{"class":612},[258,1906,1907,1909],{"class":260,"line":304},[258,1908,1286],{"class":606},[258,1910,677],{"class":612},[258,1912,1913,1915],{"class":260,"line":309},[258,1914,674],{"class":606},[258,1916,677],{"class":264},[244,1918,1919,1920,1923],{},"Enrichers receive the full ",[255,1921,1922],{},"EnrichContext"," with the mutable event, request metadata, safe headers, and response info.",[565,1925,1927,1928,999],{"id":1926},"_9-drain-evlogdrain","9. Drain (",[255,1929,1930],{},"evlog:drain",[244,1932,1933,1934,1936,1937,1940],{},"The final step sends the enriched event to your observability platform. The ",[255,1935,1930],{}," hook receives a ",[255,1938,1939],{},"DrainContext"," with the complete event:",[248,1942,1945],{"className":582,"code":1943,"filename":1944,"language":585,"meta":253,"style":253},"import { createAxiomDrain } from 'evlog\u002Faxiom'\n\nexport default defineNitroPlugin((nitroApp) => {\n  nitroApp.hooks.hook('evlog:drain', createAxiomDrain())\n})\n","server\u002Fplugins\u002Fevlog-drain.ts",[255,1946,1947,1967,1971,1991,2018],{"__ignoreMap":253},[258,1948,1949,1951,1953,1956,1958,1960,1962,1965],{"class":260,"line":261},[258,1950,1768],{"class":592},[258,1952,851],{"class":606},[258,1954,1955],{"class":264}," createAxiomDrain",[258,1957,883],{"class":606},[258,1959,1783],{"class":592},[258,1961,1130],{"class":606},[258,1963,1964],{"class":625},"evlog\u002Faxiom",[258,1966,1791],{"class":606},[258,1968,1969],{"class":260,"line":268},[258,1970,811],{"emptyLinePlaceholder":810},[258,1972,1973,1975,1977,1979,1981,1983,1985,1987,1989],{"class":260,"line":274},[258,1974,593],{"class":592},[258,1976,596],{"class":592},[258,1978,1177],{"class":599},[258,1980,603],{"class":264},[258,1982,603],{"class":606},[258,1984,1185],{"class":1184},[258,1986,999],{"class":606},[258,1988,1190],{"class":792},[258,1990,644],{"class":606},[258,1992,1993,1995,1997,1999,2001,2003,2005,2007,2009,2011,2013,2015],{"class":260,"line":280},[258,1994,1197],{"class":264},[258,1996,770],{"class":606},[258,1998,1202],{"class":264},[258,2000,770],{"class":606},[258,2002,1207],{"class":599},[258,2004,603],{"class":612},[258,2006,622],{"class":606},[258,2008,1930],{"class":625},[258,2010,622],{"class":606},[258,2012,866],{"class":606},[258,2014,1955],{"class":599},[258,2016,2017],{"class":612},"())\n",[258,2019,2020,2022],{"class":260,"line":286},[258,2021,674],{"class":606},[258,2023,677],{"class":264},[244,2025,2026,2027,2030],{},"On platforms with ",[255,2028,2029],{},"waitUntil"," (Cloudflare Workers, Vercel Edge), the drain runs after the response is sent to avoid adding latency. On traditional servers, the drain is awaited to prevent losing events in serverless cold shutdowns.",[560,2032,2034],{"id":2033},"hook-execution-order","Hook Execution Order",[690,2036,2037,2053],{},[693,2038,2039],{},[696,2040,2041,2044,2047,2050],{},[699,2042,2043],{},"Order",[699,2045,2046],{},"Hook",[699,2048,2049],{},"When",[699,2051,2052],{},"Purpose",[706,2054,2055,2070,2085],{},[696,2056,2057,2060,2064,2067],{},[711,2058,2059],{},"1",[711,2061,2062],{},[255,2063,1034],{},[711,2065,2066],{},"After request ends, before sampling",[711,2068,2069],{},"Force-keep events based on outcome",[696,2071,2072,2075,2079,2082],{},[711,2073,2074],{},"2",[711,2076,2077],{},[255,2078,1674],{},[711,2080,2081],{},"After emit, before drain",[711,2083,2084],{},"Add derived context to the event",[696,2086,2087,2090,2094,2097],{},[711,2088,2089],{},"3",[711,2091,2092],{},[255,2093,1930],{},[711,2095,2096],{},"After enrichment",[711,2098,2099],{},"Send event to external services",[560,2101,2103],{"id":2102},"error-vs-success-path","Error vs Success Path",[244,2105,2106,2107,2110],{},"Both paths converge at the same emit\u002Fenrich\u002Fdrain pipeline. The only difference is ",[1043,2108,2109],{},"when"," the emit is triggered:",[690,2112,2113,2125],{},[693,2114,2115],{},[696,2116,2117,2119,2122],{},[699,2118],{},[699,2120,2121],{},"Success",[699,2123,2124],{},"Error",[706,2126,2127,2147,2165,2181,2202],{},[696,2128,2129,2134,2143],{},[711,2130,2131],{},[989,2132,2133],{},"Trigger",[711,2135,2136,575,2139,2142],{},[255,2137,2138],{},"afterResponse",[255,2140,2141],{},"response"," hook",[711,2144,2145,2142],{},[255,2146,973],{},[696,2148,2149,2153,2161],{},[711,2150,2151],{},[989,2152,1013],{},[711,2154,2155,2157,2158,2160],{},[255,2156,1024],{}," (or ",[255,2159,1020],{}," if status >= 400)",[711,2162,2163],{},[255,2164,973],{},[696,2166,2167,2172,2175],{},[711,2168,2169],{},[989,2170,2171],{},"Status",[711,2173,2174],{},"From response",[711,2176,2177,2178,2180],{},"From error's ",[255,2179,995],{}," field (default 500)",[696,2182,2183,2188,2191],{},[711,2184,2185],{},[989,2186,2187],{},"Error context",[711,2189,2190],{},"None",[711,2192,2193,2195,2196,722,2199],{},[255,2194,973],{}," field with message, stack, ",[255,2197,2198],{},"why",[255,2200,2201],{},"fix",[696,2203,2204,2209,2216],{},[711,2205,2206],{},[989,2207,2208],{},"Double-emit guard",[711,2210,2211,2212,2215],{},"Checks ",[255,2213,2214],{},"_evlogEmitted"," flag",[711,2217,2218,2219],{},"Sets ",[255,2220,2221],{},"_evlogEmitted = true",[560,2223,2225],{"id":2224},"next-steps","Next Steps",[983,2227,2228,2234,2239,2244],{},[986,2229,2230,2233],{},[2231,2232,121],"a",{"href":122}," - Design effective wide events",[986,2235,2236,2238],{},[2231,2237,140],{"href":141}," - Configure head and tail sampling",[986,2240,2241,2243],{},[2231,2242,155],{"href":160}," - Send events to external platforms",[986,2245,2246,2248],{},[2231,2247,209],{"href":214}," - Add derived context automatically",[2250,2251,2252],"style",{},"html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}html pre.shiki code .sfNiH, html code.shiki .sfNiH{--shiki-light:#FF5370;--shiki-default:#FF9CAC;--shiki-dark:#FF9CAC}",{"title":253,"searchDepth":268,"depth":268,"links":2254},[2255,2269,2270,2271],{"id":562,"depth":268,"text":563,"children":2256},[2257,2258,2259,2260,2261,2263,2264,2265,2267],{"id":567,"depth":274,"text":568},{"id":680,"depth":274,"text":681},{"id":773,"depth":274,"text":774},{"id":977,"depth":274,"text":978},{"id":1030,"depth":274,"text":2262},"5. Tail Sampling (evlog:emit:keep)",{"id":1307,"depth":274,"text":1308},{"id":1409,"depth":274,"text":1410},{"id":1670,"depth":274,"text":2266},"8. Enrich (evlog:enrich)",{"id":1926,"depth":274,"text":2268},"9. Drain (evlog:drain)",{"id":2033,"depth":268,"text":2034},{"id":2102,"depth":268,"text":2103},{"id":2224,"depth":268,"text":2225},"Understand the full lifecycle of a request in evlog, from creation to drain. Every step from logger creation, context accumulation, sampling, enrichment, to external delivery.","md",[2275,2278],{"label":121,"icon":124,"to":122,"color":2276,"variant":2277},"neutral","subtle",{"label":140,"icon":143,"to":141,"color":2276,"variant":2277},{},{"icon":119},{"title":116,"description":2272},"gf-r8f65cFu7LMxLLtMwouLqbRj8XulXan11-ErAyco",[2284,2286],{"title":106,"path":107,"stem":108,"description":2285,"icon":109,"children":-1},"Build your own evlog framework integration using the toolkit API with createMiddlewareLogger, header extraction, AsyncLocalStorage, and the full drain\u002Fenrich\u002Fkeep pipeline.",{"title":121,"path":122,"stem":123,"description":2287,"icon":124,"children":-1},"Learn how to design effective wide events that capture everything you need in a single log. One comprehensive event per request with full context.",1773504120301]