[{"data":1,"prerenderedAt":2837},["ShallowReactive",2],{"navigation_docs":3,"-core-concepts-lifecycle":277,"-core-concepts-lifecycle-surround":2832},[4,30,65,105,188,247,263],{"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},"Logging","\u002Flogging","2.logging",[35,40,45,50,55,60],{"title":36,"path":37,"stem":38,"icon":39},"Overview","\u002Flogging\u002Foverview","2.logging\u002F0.overview","i-lucide-list",{"title":41,"path":42,"stem":43,"icon":44},"Simple Logging","\u002Flogging\u002Fsimple-logging","2.logging\u002F1.simple-logging","i-lucide-terminal",{"title":46,"path":47,"stem":48,"icon":49},"Wide Events","\u002Flogging\u002Fwide-events","2.logging\u002F2.wide-events","i-lucide-layers",{"title":51,"path":52,"stem":53,"icon":54},"Structured Errors","\u002Flogging\u002Fstructured-errors","2.logging\u002F3.structured-errors","i-lucide-shield-alert",{"title":56,"path":57,"stem":58,"icon":59},"Client Logging","\u002Flogging\u002Fclient-logging","2.logging\u002F4.client-logging","i-lucide-monitor",{"title":61,"path":62,"stem":63,"icon":64},"AI SDK Integration","\u002Flogging\u002Fai-sdk","2.logging\u002F5.ai-sdk","i-simple-icons-vercel",{"title":66,"path":67,"stem":68,"children":69,"page":29},"Core Concepts","\u002Fcore-concepts","3.core-concepts",[70,75,80,85,90,95,100],{"title":71,"path":72,"stem":73,"icon":74},"Lifecycle","\u002Fcore-concepts\u002Flifecycle","3.core-concepts\u002F0.lifecycle","i-lucide-arrow-right-left",{"title":76,"path":77,"stem":78,"icon":79},"Configuration","\u002Fcore-concepts\u002Fconfiguration","3.core-concepts\u002F1.configuration","i-lucide-settings",{"title":81,"path":82,"stem":83,"icon":84},"Sampling","\u002Fcore-concepts\u002Fsampling","3.core-concepts\u002F2.sampling","i-lucide-filter",{"title":86,"path":87,"stem":88,"icon":89},"Typed Fields","\u002Fcore-concepts\u002Ftyped-fields","3.core-concepts\u002F3.typed-fields","i-simple-icons-typescript",{"title":91,"path":92,"stem":93,"icon":94},"Best Practices","\u002Fcore-concepts\u002Fbest-practices","3.core-concepts\u002F4.best-practices","i-lucide-shield-check",{"title":96,"path":97,"stem":98,"icon":99},"Performance","\u002Fcore-concepts\u002Fperformance","3.core-concepts\u002F5.performance","i-lucide-gauge",{"title":101,"path":102,"stem":103,"icon":104},"Vite Plugin","\u002Fcore-concepts\u002Fvite-plugin","3.core-concepts\u002F6.vite-plugin","i-custom-vite",{"title":106,"path":107,"stem":108,"children":109,"page":29},"Frameworks","\u002Fframeworks","4.frameworks",[110,114,119,124,129,134,139,144,149,154,159,164,169,174,178,183],{"title":36,"path":111,"stem":112,"icon":113},"\u002Fframeworks\u002Foverview","4.frameworks\u002F00.overview","i-lucide-layout-grid",{"title":115,"path":116,"stem":117,"icon":118},"Nuxt","\u002Fframeworks\u002Fnuxt","4.frameworks\u002F01.nuxt","i-simple-icons-nuxtdotjs",{"title":120,"path":121,"stem":122,"icon":123},"Next.js","\u002Fframeworks\u002Fnextjs","4.frameworks\u002F02.nextjs","i-simple-icons-nextdotjs",{"title":125,"path":126,"stem":127,"icon":128},"SvelteKit","\u002Fframeworks\u002Fsveltekit","4.frameworks\u002F03.sveltekit","i-simple-icons-svelte",{"title":130,"path":131,"stem":132,"icon":133},"Nitro","\u002Fframeworks\u002Fnitro","4.frameworks\u002F04.nitro","i-custom-nitro",{"title":135,"path":136,"stem":137,"icon":138},"TanStack Start","\u002Fframeworks\u002Ftanstack-start","4.frameworks\u002F05.tanstack-start","i-custom-tanstack",{"title":140,"path":141,"stem":142,"icon":143},"NestJS","\u002Fframeworks\u002Fnestjs","4.frameworks\u002F06.nestjs","i-simple-icons-nestjs",{"title":145,"path":146,"stem":147,"icon":148},"Express","\u002Fframeworks\u002Fexpress","4.frameworks\u002F07.express","i-simple-icons-express",{"title":150,"path":151,"stem":152,"icon":153},"Hono","\u002Fframeworks\u002Fhono","4.frameworks\u002F08.hono","i-simple-icons-hono",{"title":155,"path":156,"stem":157,"icon":158},"Fastify","\u002Fframeworks\u002Ffastify","4.frameworks\u002F09.fastify","i-simple-icons-fastify",{"title":160,"path":161,"stem":162,"icon":163},"Elysia","\u002Fframeworks\u002Felysia","4.frameworks\u002F10.elysia","i-custom-elysia",{"title":165,"path":166,"stem":167,"icon":168},"React Router","\u002Fframeworks\u002Freact-router","4.frameworks\u002F11.react-router","i-custom-reactrouter",{"title":170,"path":171,"stem":172,"icon":173},"Cloudflare Workers","\u002Fframeworks\u002Fcloudflare-workers","4.frameworks\u002F12.cloudflare-workers","i-simple-icons-cloudflare",{"title":175,"path":176,"stem":177,"icon":89},"Standalone","\u002Fframeworks\u002Fstandalone","4.frameworks\u002F13.standalone",{"title":179,"path":180,"stem":181,"icon":182},"Astro","\u002Fframeworks\u002Fastro","4.frameworks\u002F14.astro","i-simple-icons-astro",{"title":184,"path":185,"stem":186,"icon":187},"Custom Integration","\u002Fframeworks\u002Fcustom-integration","4.frameworks\u002F15.custom-integration","i-lucide-puzzle",{"title":189,"path":190,"stem":191,"children":192,"page":29},"Adapters","\u002Fadapters","5.adapters",[193,197,202,207,212,217,222,227,232,237,242],{"title":36,"path":194,"stem":195,"icon":196},"\u002Fadapters\u002Foverview","5.adapters\u002F1.overview","i-custom-plug",{"title":198,"path":199,"stem":200,"icon":201},"Pipeline","\u002Fadapters\u002Fpipeline","5.adapters\u002F10.pipeline","i-lucide-workflow",{"title":203,"path":204,"stem":205,"icon":206},"Browser","\u002Fadapters\u002Fbrowser","5.adapters\u002F11.browser","i-lucide-globe",{"title":208,"path":209,"stem":210,"icon":211},"Axiom","\u002Fadapters\u002Faxiom","5.adapters\u002F2.axiom","i-custom-axiom",{"title":213,"path":214,"stem":215,"icon":216},"OTLP","\u002Fadapters\u002Fotlp","5.adapters\u002F3.otlp","i-simple-icons-opentelemetry",{"title":218,"path":219,"stem":220,"icon":221},"PostHog","\u002Fadapters\u002Fposthog","5.adapters\u002F4.posthog","i-simple-icons-posthog",{"title":223,"path":224,"stem":225,"icon":226},"Sentry","\u002Fadapters\u002Fsentry","5.adapters\u002F5.sentry","i-simple-icons-sentry",{"title":228,"path":229,"stem":230,"icon":231},"Better Stack","\u002Fadapters\u002Fbetter-stack","5.adapters\u002F6.better-stack","i-simple-icons-betterstack",{"title":233,"path":234,"stem":235,"icon":236},"File System","\u002Fadapters\u002Ffs","5.adapters\u002F7.fs","i-lucide-hard-drive",{"title":238,"path":239,"stem":240,"icon":241},"HyperDX","\u002Fadapters\u002Fhyperdx","5.adapters\u002F8.hyperdx","i-custom-hyperdx",{"title":243,"path":244,"stem":245,"icon":246},"Custom Adapters","\u002Fadapters\u002Fcustom","5.adapters\u002F9.custom","i-lucide-code",{"title":248,"path":249,"stem":250,"children":251,"page":29},"Enrichers","\u002Fenrichers","6.enrichers",[252,255,259],{"title":36,"path":253,"stem":254,"icon":28},"\u002Fenrichers\u002Foverview","6.enrichers\u002F1.overview",{"title":256,"path":257,"stem":258,"icon":187},"Built-in","\u002Fenrichers\u002Fbuilt-in","6.enrichers\u002F2.built-in",{"title":260,"path":261,"stem":262,"icon":246},"Custom","\u002Fenrichers\u002Fcustom","6.enrichers\u002F3.custom",{"title":264,"path":265,"stem":266,"children":267,"page":29},"NuxtHub","\u002Fnuxthub","7.nuxthub",[268,272],{"title":36,"path":269,"stem":270,"icon":271},"\u002Fnuxthub\u002Foverview","7.nuxthub\u002F1.overview","i-lucide-database",{"title":273,"path":274,"stem":275,"icon":276},"Retention","\u002Fnuxthub\u002Fretention","7.nuxthub\u002F2.retention","i-lucide-clock",{"id":278,"title":71,"body":279,"description":2821,"extension":2822,"links":2823,"meta":2828,"navigation":2829,"path":72,"seo":2830,"stem":73,"__hash__":2831},"docs\u002F3.core-concepts\u002F0.lifecycle.md",{"type":280,"value":281,"toc":2798},"minimark",[282,286,291,436,440,446,757,761,766,776,782,880,884,891,960,966,970,976,1189,1196,1200,1203,1245,1248,1255,1267,1375,1381,1513,1523,1527,1530,1537,1606,1629,1632,1636,1642,1890,1893,1900,1903,1983,2139,2146,2153,2163,2246,2253,2257,2322,2326,2333,2444,2448,2454,2487,2497,2501,2508,2556,2767,2771,2794],[283,284,285],"p",{},"evlog events follow a pipeline from creation to delivery. The pipeline differs slightly depending on which logging mode you use, but the core stages (emit, sample, enrich, drain) are shared.",[287,288,290],"h2",{"id":289},"overview-by-mode","Overview by Mode",[292,293,294,323],"table",{},[295,296,297],"thead",{},[298,299,300,304,311,320],"tr",{},[301,302,303],"th",{},"Stage",[301,305,306,310],{},[307,308,309],"code",{},"log"," (simple)",[301,312,313,316,317],{},[307,314,315],{},"createLogger"," \u002F ",[307,318,319],{},"createRequestLogger",[301,321,322],{},"Framework middleware",[324,325,326,350,374,393,408,423],"tbody",{},[298,327,328,335,338,347],{},[329,330,331],"td",{},[332,333,334],"strong",{},"Create",[329,336,337],{},"Implicit per call",[329,339,340,343,344],{},[307,341,342],{},"createLogger({...})"," or ",[307,345,346],{},"createRequestLogger({...})",[329,348,349],{},"Auto on request start",[298,351,352,357,360,366],{},[329,353,354],{},[332,355,356],{},"Accumulate",[329,358,359],{},"N\u002FA (single call)",[329,361,362,365],{},[307,363,364],{},"log.set()"," multiple times",[329,367,368,370,371],{},[307,369,364],{}," via ",[307,372,373],{},"useLogger(event)",[298,375,376,381,384,390],{},[329,377,378],{},[332,379,380],{},"Emit",[329,382,383],{},"Immediate",[329,385,386,387],{},"Manual ",[307,388,389],{},"log.emit()",[329,391,392],{},"Auto on response end",[298,394,395,400,403,406],{},[329,396,397],{},[332,398,399],{},"Sample",[329,401,402],{},"Head sampling only",[329,404,405],{},"Head + tail sampling",[329,407,405],{},[298,409,410,415,418,420],{},[329,411,412],{},[332,413,414],{},"Enrich",[329,416,417],{},"Via global drain",[329,419,417],{},[329,421,422],{},"Via hooks or callbacks",[298,424,425,430,432,434],{},[329,426,427],{},[332,428,429],{},"Drain",[329,431,417],{},[329,433,417],{},[329,435,422],{},[287,437,439],{"id":438},"request-logging-pipeline","Request Logging Pipeline",[283,441,442,443,445],{},"For framework-managed request logging, every request follows this pipeline. The middleware creates the logger and ",[307,444,373],{}," retrieves it:",[447,448,453],"pre",{"className":449,"code":450,"language":451,"meta":452,"style":452},"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","",[307,454,455,464,470,476,482,488,494,500,505,511,517,523,528,533,538,544,550,555,560,565,570,576,581,586,591,596,602,608,613,618,623,628,634,640,645,651,656,661,666,672,677,682,687,692,698,704,709,714,719,724,730,736,741,746,751],{"__ignoreMap":452},[456,457,460],"span",{"class":458,"line":459},"line",1,[456,461,463],{"class":462},"sTEyZ","   Request In\n",[456,465,467],{"class":458,"line":466},2,[456,468,469],{"class":462},"       │\n",[456,471,473],{"class":458,"line":472},3,[456,474,475],{"class":462},"       ▼\n",[456,477,479],{"class":458,"line":478},4,[456,480,481],{"class":462},"  ┌──────────┐     Route excluded?\n",[456,483,485],{"class":458,"line":484},5,[456,486,487],{"class":462},"  │  Filter  │────── yes ──▶ skip (no logging)\n",[456,489,491],{"class":458,"line":490},6,[456,492,493],{"class":462},"  └──────────┘\n",[456,495,497],{"class":458,"line":496},7,[456,498,499],{"class":462},"       │ no\n",[456,501,503],{"class":458,"line":502},8,[456,504,475],{"class":462},[456,506,508],{"class":458,"line":507},9,[456,509,510],{"class":462},"  ┌──────────────────┐\n",[456,512,514],{"class":458,"line":513},10,[456,515,516],{"class":462},"  │  Create Logger   │  requestId, method, path, startTime\n",[456,518,520],{"class":458,"line":519},11,[456,521,522],{"class":462},"  └──────────────────┘\n",[456,524,526],{"class":458,"line":525},12,[456,527,469],{"class":462},[456,529,531],{"class":458,"line":530},13,[456,532,475],{"class":462},[456,534,536],{"class":458,"line":535},14,[456,537,510],{"class":462},[456,539,541],{"class":458,"line":540},15,[456,542,543],{"class":462},"  │  Handler runs    │  log.set() accumulates context\n",[456,545,547],{"class":458,"line":546},16,[456,548,549],{"class":462},"  │                  │  log.error() records errors\n",[456,551,553],{"class":458,"line":552},17,[456,554,522],{"class":462},[456,556,558],{"class":458,"line":557},18,[456,559,469],{"class":462},[456,561,563],{"class":458,"line":562},19,[456,564,475],{"class":462},[456,566,568],{"class":458,"line":567},20,[456,569,510],{"class":462},[456,571,573],{"class":458,"line":572},21,[456,574,575],{"class":462},"  │  Request ends    │  status + duration computed\n",[456,577,579],{"class":458,"line":578},22,[456,580,522],{"class":462},[456,582,584],{"class":458,"line":583},23,[456,585,469],{"class":462},[456,587,589],{"class":458,"line":588},24,[456,590,475],{"class":462},[456,592,594],{"class":458,"line":593},25,[456,595,510],{"class":462},[456,597,599],{"class":458,"line":598},26,[456,600,601],{"class":462},"  │  Tail Sampling   │  evlog:emit:keep hook\n",[456,603,605],{"class":458,"line":604},27,[456,606,607],{"class":462},"  │  (keep?)         │  force-keep based on outcome\n",[456,609,611],{"class":458,"line":610},28,[456,612,522],{"class":462},[456,614,616],{"class":458,"line":615},29,[456,617,469],{"class":462},[456,619,621],{"class":458,"line":620},30,[456,622,475],{"class":462},[456,624,626],{"class":458,"line":625},31,[456,627,510],{"class":462},[456,629,631],{"class":458,"line":630},32,[456,632,633],{"class":462},"  │  Head Sampling   │  random % per level\n",[456,635,637],{"class":458,"line":636},33,[456,638,639],{"class":462},"  │  (sample?)       │  skipped if tail said \"keep\"\n",[456,641,643],{"class":458,"line":642},34,[456,644,522],{"class":462},[456,646,648],{"class":458,"line":647},35,[456,649,650],{"class":462},"       │ sampled out? ──▶ discard (no output)\n",[456,652,654],{"class":458,"line":653},36,[456,655,469],{"class":462},[456,657,659],{"class":458,"line":658},37,[456,660,475],{"class":462},[456,662,664],{"class":458,"line":663},38,[456,665,510],{"class":462},[456,667,669],{"class":458,"line":668},39,[456,670,671],{"class":462},"  │  Emit            │  WideEvent built + console output\n",[456,673,675],{"class":458,"line":674},40,[456,676,522],{"class":462},[456,678,680],{"class":458,"line":679},41,[456,681,469],{"class":462},[456,683,685],{"class":458,"line":684},42,[456,686,475],{"class":462},[456,688,690],{"class":458,"line":689},43,[456,691,510],{"class":462},[456,693,695],{"class":458,"line":694},44,[456,696,697],{"class":462},"  │  Enrich          │  evlog:enrich hook\n",[456,699,701],{"class":458,"line":700},45,[456,702,703],{"class":462},"  │                  │  user-agent, geo, trace, custom\n",[456,705,707],{"class":458,"line":706},46,[456,708,522],{"class":462},[456,710,712],{"class":458,"line":711},47,[456,713,469],{"class":462},[456,715,717],{"class":458,"line":716},48,[456,718,475],{"class":462},[456,720,722],{"class":458,"line":721},49,[456,723,510],{"class":462},[456,725,727],{"class":458,"line":726},50,[456,728,729],{"class":462},"  │  Drain           │  evlog:drain hook\n",[456,731,733],{"class":458,"line":732},51,[456,734,735],{"class":462},"  │                  │  Axiom, OTLP, Sentry, custom\n",[456,737,739],{"class":458,"line":738},52,[456,740,522],{"class":462},[456,742,744],{"class":458,"line":743},53,[456,745,469],{"class":462},[456,747,749],{"class":458,"line":748},54,[456,750,475],{"class":462},[456,752,754],{"class":458,"line":753},55,[456,755,756],{"class":462},"   Done\n",[287,758,760],{"id":759},"step-by-step","Step by Step",[762,763,765],"h3",{"id":764},"_1-route-filtering","1. Route Filtering",[283,767,768,769,316,772,775],{},"When a request arrives, evlog checks whether the path matches the configured ",[307,770,771],{},"include",[307,773,774],{},"exclude"," patterns. If the route is excluded, no logger is created and the request proceeds without any logging overhead.",[283,777,778,779,781],{},"By default, all routes are logged. Use ",[307,780,771],{}," to restrict logging to specific patterns:",[447,783,788],{"className":784,"code":785,"filename":786,"language":787,"meta":452,"style":452},"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",[307,789,790,810,837,847,867,872],{"__ignoreMap":452},[456,791,792,796,799,803,806],{"class":458,"line":459},[456,793,795],{"class":794},"s7zQu","export",[456,797,798],{"class":794}," default",[456,800,802],{"class":801},"s2Zo4"," defineNuxtConfig",[456,804,805],{"class":462},"(",[456,807,809],{"class":808},"sMK4o","{\n",[456,811,812,816,819,822,825,829,831,834],{"class":458,"line":466},[456,813,815],{"class":814},"swJcz","  modules",[456,817,818],{"class":808},":",[456,820,821],{"class":462}," [",[456,823,824],{"class":808},"'",[456,826,828],{"class":827},"sfazB","evlog\u002Fnuxt",[456,830,824],{"class":808},[456,832,833],{"class":462},"]",[456,835,836],{"class":808},",\n",[456,838,839,842,844],{"class":458,"line":472},[456,840,841],{"class":814},"  evlog",[456,843,818],{"class":808},[456,845,846],{"class":808}," {\n",[456,848,849,852,854,856,858,861,863,865],{"class":458,"line":478},[456,850,851],{"class":814},"    include",[456,853,818],{"class":808},[456,855,821],{"class":462},[456,857,824],{"class":808},[456,859,860],{"class":827},"\u002Fapi\u002F**",[456,862,824],{"class":808},[456,864,833],{"class":462},[456,866,836],{"class":808},[456,868,869],{"class":458,"line":484},[456,870,871],{"class":808},"  },\n",[456,873,874,877],{"class":458,"line":490},[456,875,876],{"class":808},"}",[456,878,879],{"class":462},")\n",[762,881,883],{"id":882},"_2-logger-creation","2. Logger Creation",[283,885,886,887,890],{},"For matched routes, evlog creates a ",[307,888,889],{},"RequestLogger"," and attaches it to the request context. The logger is pre-populated with:",[292,892,893,903],{},[295,894,895],{},[298,896,897,900],{},[301,898,899],{},"Field",[301,901,902],{},"Source",[324,904,905,923,933,947],{},[298,906,907,912],{},[329,908,909],{},[307,910,911],{},"method",[329,913,914,915,918,919,922],{},"HTTP method (",[307,916,917],{},"GET",", ",[307,920,921],{},"POST",", ...)",[298,924,925,930],{},[329,926,927],{},[307,928,929],{},"path",[329,931,932],{},"Request path",[298,934,935,940],{},[329,936,937],{},[307,938,939],{},"requestId",[329,941,942,943,946],{},"Auto-generated UUID (or ",[307,944,945],{},"cf-ray"," on Cloudflare)",[298,948,949,954],{},[329,950,951],{},[307,952,953],{},"startTime",[329,955,956,959],{},[307,957,958],{},"Date.now()"," for duration calculation",[283,961,962,963,965],{},"The logger is stored on the event context. ",[307,964,373],{}," is a shortcut to retrieve it, it doesn't create a new logger.",[762,967,969],{"id":968},"_3-context-accumulation","3. Context Accumulation",[283,971,972,973,975],{},"During the handler, you call ",[307,974,364],{}," to attach context. Each call deep-merges into the existing context, so you can call it as many times as needed:",[447,977,980],{"className":784,"code":978,"filename":979,"language":787,"meta":452,"style":452},"import { useLogger } from 'evlog'\n\nconst 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",[307,981,982,1008,1014,1031,1035,1052,1107,1111,1133],{"__ignoreMap":452},[456,983,984,987,990,993,996,999,1002,1005],{"class":458,"line":459},[456,985,986],{"class":794},"import",[456,988,989],{"class":808}," {",[456,991,992],{"class":462}," useLogger",[456,994,995],{"class":808}," }",[456,997,998],{"class":794}," from",[456,1000,1001],{"class":808}," '",[456,1003,1004],{"class":827},"evlog",[456,1006,1007],{"class":808},"'\n",[456,1009,1010],{"class":458,"line":466},[456,1011,1013],{"emptyLinePlaceholder":1012},true,"\n",[456,1015,1016,1020,1023,1026,1028],{"class":458,"line":472},[456,1017,1019],{"class":1018},"spNyl","const",[456,1021,1022],{"class":462}," log ",[456,1024,1025],{"class":808},"=",[456,1027,992],{"class":801},[456,1029,1030],{"class":462},"(event)\n",[456,1032,1033],{"class":458,"line":478},[456,1034,1013],{"emptyLinePlaceholder":1012},[456,1036,1037,1039,1042,1044,1047,1050],{"class":458,"line":484},[456,1038,1019],{"class":1018},[456,1040,1041],{"class":462}," user ",[456,1043,1025],{"class":808},[456,1045,1046],{"class":794}," await",[456,1048,1049],{"class":801}," getUser",[456,1051,1030],{"class":462},[456,1053,1054,1056,1059,1062,1064,1067,1070,1072,1074,1077,1079,1081,1083,1086,1089,1092,1094,1096,1098,1101,1103,1105],{"class":458,"line":490},[456,1055,309],{"class":462},[456,1057,1058],{"class":808},".",[456,1060,1061],{"class":801},"set",[456,1063,805],{"class":462},[456,1065,1066],{"class":808},"{",[456,1068,1069],{"class":814}," user",[456,1071,818],{"class":808},[456,1073,989],{"class":808},[456,1075,1076],{"class":814}," id",[456,1078,818],{"class":808},[456,1080,1069],{"class":462},[456,1082,1058],{"class":808},[456,1084,1085],{"class":462},"id",[456,1087,1088],{"class":808},",",[456,1090,1091],{"class":814}," plan",[456,1093,818],{"class":808},[456,1095,1069],{"class":462},[456,1097,1058],{"class":808},[456,1099,1100],{"class":462},"plan ",[456,1102,876],{"class":808},[456,1104,995],{"class":808},[456,1106,879],{"class":462},[456,1108,1109],{"class":458,"line":496},[456,1110,1013],{"emptyLinePlaceholder":1012},[456,1112,1113,1115,1118,1120,1122,1125,1128,1130],{"class":458,"line":502},[456,1114,1019],{"class":1018},[456,1116,1117],{"class":462}," cart ",[456,1119,1025],{"class":808},[456,1121,1046],{"class":794},[456,1123,1124],{"class":801}," getCart",[456,1126,1127],{"class":462},"(user",[456,1129,1058],{"class":808},[456,1131,1132],{"class":462},"id)\n",[456,1134,1135,1137,1139,1141,1143,1145,1148,1150,1152,1155,1157,1159,1161,1164,1166,1169,1171,1174,1176,1178,1180,1183,1185,1187],{"class":458,"line":507},[456,1136,309],{"class":462},[456,1138,1058],{"class":808},[456,1140,1061],{"class":801},[456,1142,805],{"class":462},[456,1144,1066],{"class":808},[456,1146,1147],{"class":814}," cart",[456,1149,818],{"class":808},[456,1151,989],{"class":808},[456,1153,1154],{"class":814}," items",[456,1156,818],{"class":808},[456,1158,1147],{"class":462},[456,1160,1058],{"class":808},[456,1162,1163],{"class":462},"items",[456,1165,1058],{"class":808},[456,1167,1168],{"class":462},"length",[456,1170,1088],{"class":808},[456,1172,1173],{"class":814}," total",[456,1175,818],{"class":808},[456,1177,1147],{"class":462},[456,1179,1058],{"class":808},[456,1181,1182],{"class":462},"total ",[456,1184,876],{"class":808},[456,1186,995],{"class":808},[456,1188,879],{"class":462},[283,1190,1191,1192,1195],{},"If an error is thrown, evlog's ",[307,1193,1194],{},"error"," hook captures it automatically and records it on the logger with the status code.",[762,1197,1199],{"id":1198},"_4-request-end","4. Request End",[283,1201,1202],{},"When the response is sent (or an error is thrown), evlog computes:",[1204,1205,1206,1220,1229],"ul",{},[1207,1208,1209,1212,1213,316,1216,1219],"li",{},[332,1210,1211],{},"Status code"," from the response (or from the error's ",[307,1214,1215],{},"status",[307,1217,1218],{},"statusCode",")",[1207,1221,1222,1225,1226],{},[332,1223,1224],{},"Duration"," from ",[307,1227,1228],{},"Date.now() - startTime",[1207,1230,1231,1234,1235,1237,1238,1241,1242],{},[332,1232,1233],{},"Level"," - ",[307,1236,1194],{}," if an error was recorded, ",[307,1239,1240],{},"warn"," if status >= 400, otherwise ",[307,1243,1244],{},"info",[283,1246,1247],{},"If an error triggered the emit, the request is marked as already emitted to prevent double-emission in the response hook.",[762,1249,1251,1252,1219],{"id":1250},"_5-tail-sampling-evlogemitkeep","5. Tail Sampling (",[307,1253,1254],{},"evlog:emit:keep",[283,1256,1257,1258,1261,1262,1266],{},"Before the event is sampled, evlog evaluates ",[332,1259,1260],{},"tail sampling"," rules. These run ",[1263,1264,1265],"em",{},"after"," the request completes, so they can inspect the outcome:",[447,1268,1270],{"className":784,"code":1269,"filename":786,"language":787,"meta":452,"style":452},"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",[307,1271,1272,1281,1290,1300,1321,1338,1359,1366,1370],{"__ignoreMap":452},[456,1273,1274,1277,1279],{"class":458,"line":459},[456,1275,1004],{"class":1276},"sBMFI",[456,1278,818],{"class":808},[456,1280,846],{"class":808},[456,1282,1283,1286,1288],{"class":458,"line":466},[456,1284,1285],{"class":1276},"  sampling",[456,1287,818],{"class":808},[456,1289,846],{"class":808},[456,1291,1292,1295,1297],{"class":458,"line":472},[456,1293,1294],{"class":1276},"    keep",[456,1296,818],{"class":808},[456,1298,1299],{"class":814}," [\n",[456,1301,1302,1305,1308,1310,1314,1317],{"class":458,"line":478},[456,1303,1304],{"class":808},"      {",[456,1306,1307],{"class":814}," duration",[456,1309,818],{"class":808},[456,1311,1313],{"class":1312},"sbssI"," 1000",[456,1315,1316],{"class":808}," },",[456,1318,1320],{"class":1319},"sHwdD","          \u002F\u002F slow requests\n",[456,1322,1323,1325,1328,1330,1333,1335],{"class":458,"line":484},[456,1324,1304],{"class":808},[456,1326,1327],{"class":814}," status",[456,1329,818],{"class":808},[456,1331,1332],{"class":1312}," 400",[456,1334,1316],{"class":808},[456,1336,1337],{"class":1319},"             \u002F\u002F client\u002Fserver errors\n",[456,1339,1340,1342,1345,1347,1349,1352,1354,1356],{"class":458,"line":490},[456,1341,1304],{"class":808},[456,1343,1344],{"class":814}," path",[456,1346,818],{"class":808},[456,1348,1001],{"class":808},[456,1350,1351],{"class":827},"\u002Fapi\u002Fcritical\u002F**",[456,1353,824],{"class":808},[456,1355,1316],{"class":808},[456,1357,1358],{"class":1319}," \u002F\u002F critical paths\n",[456,1360,1361,1364],{"class":458,"line":496},[456,1362,1363],{"class":814},"    ]",[456,1365,836],{"class":808},[456,1367,1368],{"class":458,"line":502},[456,1369,871],{"class":808},[456,1371,1372],{"class":458,"line":507},[456,1373,1374],{"class":808},"}\n",[283,1376,1377,1378,1380],{},"The ",[307,1379,1254],{}," hook also fires, letting you force-keep based on custom business logic:",[447,1382,1385],{"className":784,"code":1383,"filename":1384,"language":787,"meta":452,"style":452},"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",[307,1386,1387,1411,1448,1478,1495,1500,1507],{"__ignoreMap":452},[456,1388,1389,1391,1393,1396,1398,1400,1404,1406,1409],{"class":458,"line":459},[456,1390,795],{"class":794},[456,1392,798],{"class":794},[456,1394,1395],{"class":801}," defineNitroPlugin",[456,1397,805],{"class":462},[456,1399,805],{"class":808},[456,1401,1403],{"class":1402},"sHdIc","nitroApp",[456,1405,1219],{"class":808},[456,1407,1408],{"class":1018}," =>",[456,1410,846],{"class":808},[456,1412,1413,1416,1418,1421,1423,1426,1428,1430,1432,1434,1436,1439,1442,1444,1446],{"class":458,"line":466},[456,1414,1415],{"class":462},"  nitroApp",[456,1417,1058],{"class":808},[456,1419,1420],{"class":462},"hooks",[456,1422,1058],{"class":808},[456,1424,1425],{"class":801},"hook",[456,1427,805],{"class":814},[456,1429,824],{"class":808},[456,1431,1254],{"class":827},[456,1433,824],{"class":808},[456,1435,1088],{"class":808},[456,1437,1438],{"class":808}," (",[456,1440,1441],{"class":1402},"ctx",[456,1443,1219],{"class":808},[456,1445,1408],{"class":1018},[456,1447,846],{"class":808},[456,1449,1450,1453,1455,1457,1459,1462,1464,1467,1470,1473,1476],{"class":458,"line":472},[456,1451,1452],{"class":794},"    if",[456,1454,1438],{"class":814},[456,1456,1441],{"class":462},[456,1458,1058],{"class":808},[456,1460,1461],{"class":462},"context",[456,1463,1058],{"class":808},[456,1465,1466],{"class":462},"user",[456,1468,1469],{"class":808},"?.",[456,1471,1472],{"class":462},"premium",[456,1474,1475],{"class":814},") ",[456,1477,809],{"class":808},[456,1479,1480,1483,1485,1488,1491],{"class":458,"line":478},[456,1481,1482],{"class":462},"      ctx",[456,1484,1058],{"class":808},[456,1486,1487],{"class":462},"shouldKeep",[456,1489,1490],{"class":808}," =",[456,1492,1494],{"class":1493},"sfNiH"," true\n",[456,1496,1497],{"class":458,"line":484},[456,1498,1499],{"class":808},"    }\n",[456,1501,1502,1505],{"class":458,"line":490},[456,1503,1504],{"class":808},"  }",[456,1506,879],{"class":814},[456,1508,1509,1511],{"class":458,"line":496},[456,1510,876],{"class":808},[456,1512,879],{"class":462},[283,1514,1515,1516,1519,1520,1058],{},"If any rule or hook sets ",[307,1517,1518],{},"shouldKeep = true",", the event ",[332,1521,1522],{},"bypasses head sampling entirely",[762,1524,1526],{"id":1525},"_6-head-sampling","6. Head Sampling",[283,1528,1529],{},"If the event wasn't force-kept by tail sampling, head sampling applies. This is a random coin flip per log level.",[283,1531,1532,1533,1536],{},"By default, all levels are kept at 100% (no sampling). Configure ",[307,1534,1535],{},"sampling.rates"," to reduce volume in production:",[447,1538,1540],{"className":784,"code":1539,"filename":786,"language":787,"meta":452,"style":452},"evlog: {\n  sampling: {\n    rates: { info: 10, warn: 50, debug: 0 },\n  },\n}\n",[307,1541,1542,1550,1558,1598,1602],{"__ignoreMap":452},[456,1543,1544,1546,1548],{"class":458,"line":459},[456,1545,1004],{"class":1276},[456,1547,818],{"class":808},[456,1549,846],{"class":808},[456,1551,1552,1554,1556],{"class":458,"line":466},[456,1553,1285],{"class":1276},[456,1555,818],{"class":808},[456,1557,846],{"class":808},[456,1559,1560,1563,1565,1567,1570,1572,1575,1577,1580,1582,1585,1587,1590,1592,1595],{"class":458,"line":472},[456,1561,1562],{"class":1276},"    rates",[456,1564,818],{"class":808},[456,1566,989],{"class":808},[456,1568,1569],{"class":1276}," info",[456,1571,818],{"class":808},[456,1573,1574],{"class":1312}," 10",[456,1576,1088],{"class":808},[456,1578,1579],{"class":1276}," warn",[456,1581,818],{"class":808},[456,1583,1584],{"class":1312}," 50",[456,1586,1088],{"class":808},[456,1588,1589],{"class":1276}," debug",[456,1591,818],{"class":808},[456,1593,1594],{"class":1312}," 0",[456,1596,1597],{"class":808}," },\n",[456,1599,1600],{"class":458,"line":478},[456,1601,871],{"class":808},[456,1603,1604],{"class":458,"line":484},[456,1605,1374],{"class":808},[1204,1607,1608,1614,1620],{},[1207,1609,1610,1613],{},[307,1611,1612],{},"info: 10"," - keep 10% of info-level events",[1207,1615,1616,1619],{},[307,1617,1618],{},"warn: 50"," - keep 50% of warnings",[1207,1621,1622,1624,1625,1628],{},[307,1623,1194],{}," defaults to ",[332,1626,1627],{},"100%"," (never sampled out, even if you set a rate)",[283,1630,1631],{},"If the event is sampled out, processing stops entirely: no console output, no enrichment, no drain.",[762,1633,1635],{"id":1634},"_7-emit","7. Emit",[283,1637,1377,1638,1641],{},[307,1639,1640],{},"WideEvent"," object is built from the accumulated context:",[447,1643,1647],{"className":1644,"code":1645,"filename":1640,"language":1646,"meta":452,"style":452},"language-json shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","{\n  \"timestamp\": \"2026-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",[307,1648,1649,1653,1676,1695,1715,1733,1752,1771,1787,1802,1845,1886],{"__ignoreMap":452},[456,1650,1651],{"class":458,"line":459},[456,1652,809],{"class":808},[456,1654,1655,1658,1661,1664,1666,1669,1672,1674],{"class":458,"line":466},[456,1656,1657],{"class":808},"  \"",[456,1659,1660],{"class":1018},"timestamp",[456,1662,1663],{"class":808},"\"",[456,1665,818],{"class":808},[456,1667,1668],{"class":808}," \"",[456,1670,1671],{"class":827},"2026-01-15T10:30:00.000Z",[456,1673,1663],{"class":808},[456,1675,836],{"class":808},[456,1677,1678,1680,1683,1685,1687,1689,1691,1693],{"class":458,"line":472},[456,1679,1657],{"class":808},[456,1681,1682],{"class":1018},"level",[456,1684,1663],{"class":808},[456,1686,818],{"class":808},[456,1688,1668],{"class":808},[456,1690,1244],{"class":827},[456,1692,1663],{"class":808},[456,1694,836],{"class":808},[456,1696,1697,1699,1702,1704,1706,1708,1711,1713],{"class":458,"line":478},[456,1698,1657],{"class":808},[456,1700,1701],{"class":1018},"service",[456,1703,1663],{"class":808},[456,1705,818],{"class":808},[456,1707,1668],{"class":808},[456,1709,1710],{"class":827},"my-app",[456,1712,1663],{"class":808},[456,1714,836],{"class":808},[456,1716,1717,1719,1721,1723,1725,1727,1729,1731],{"class":458,"line":484},[456,1718,1657],{"class":808},[456,1720,911],{"class":1018},[456,1722,1663],{"class":808},[456,1724,818],{"class":808},[456,1726,1668],{"class":808},[456,1728,921],{"class":827},[456,1730,1663],{"class":808},[456,1732,836],{"class":808},[456,1734,1735,1737,1739,1741,1743,1745,1748,1750],{"class":458,"line":490},[456,1736,1657],{"class":808},[456,1738,929],{"class":1018},[456,1740,1663],{"class":808},[456,1742,818],{"class":808},[456,1744,1668],{"class":808},[456,1746,1747],{"class":827},"\u002Fapi\u002Fcheckout",[456,1749,1663],{"class":808},[456,1751,836],{"class":808},[456,1753,1754,1756,1758,1760,1762,1764,1767,1769],{"class":458,"line":496},[456,1755,1657],{"class":808},[456,1757,939],{"class":1018},[456,1759,1663],{"class":808},[456,1761,818],{"class":808},[456,1763,1668],{"class":808},[456,1765,1766],{"class":827},"abc-123",[456,1768,1663],{"class":808},[456,1770,836],{"class":808},[456,1772,1773,1775,1778,1780,1782,1785],{"class":458,"line":502},[456,1774,1657],{"class":808},[456,1776,1777],{"class":1018},"duration",[456,1779,1663],{"class":808},[456,1781,818],{"class":808},[456,1783,1784],{"class":1312}," 234",[456,1786,836],{"class":808},[456,1788,1789,1791,1793,1795,1797,1800],{"class":458,"line":507},[456,1790,1657],{"class":808},[456,1792,1215],{"class":1018},[456,1794,1663],{"class":808},[456,1796,818],{"class":808},[456,1798,1799],{"class":1312}," 200",[456,1801,836],{"class":808},[456,1803,1804,1806,1808,1810,1812,1814,1816,1818,1820,1822,1825,1827,1829,1832,1834,1836,1838,1841,1843],{"class":458,"line":513},[456,1805,1657],{"class":808},[456,1807,1466],{"class":1018},[456,1809,1663],{"class":808},[456,1811,818],{"class":808},[456,1813,989],{"class":808},[456,1815,1668],{"class":808},[456,1817,1085],{"class":1276},[456,1819,1663],{"class":808},[456,1821,818],{"class":808},[456,1823,1824],{"class":1312}," 1",[456,1826,1088],{"class":808},[456,1828,1668],{"class":808},[456,1830,1831],{"class":1276},"plan",[456,1833,1663],{"class":808},[456,1835,818],{"class":808},[456,1837,1668],{"class":808},[456,1839,1840],{"class":827},"pro",[456,1842,1663],{"class":808},[456,1844,1597],{"class":808},[456,1846,1847,1849,1852,1854,1856,1858,1860,1862,1864,1866,1869,1871,1873,1876,1878,1880,1883],{"class":458,"line":519},[456,1848,1657],{"class":808},[456,1850,1851],{"class":1018},"cart",[456,1853,1663],{"class":808},[456,1855,818],{"class":808},[456,1857,989],{"class":808},[456,1859,1668],{"class":808},[456,1861,1163],{"class":1276},[456,1863,1663],{"class":808},[456,1865,818],{"class":808},[456,1867,1868],{"class":1312}," 3",[456,1870,1088],{"class":808},[456,1872,1668],{"class":808},[456,1874,1875],{"class":1276},"total",[456,1877,1663],{"class":808},[456,1879,818],{"class":808},[456,1881,1882],{"class":1312}," 9999",[456,1884,1885],{"class":808}," }\n",[456,1887,1888],{"class":458,"line":525},[456,1889,1374],{"class":808},[283,1891,1892],{},"The event is printed to the console, pretty-formatted in development and as JSON in production. This is the default behavior, no configuration needed.",[762,1894,1896,1897,1219],{"id":1895},"_8-enrich-evlogenrich","8. Enrich (",[307,1898,1899],{},"evlog:enrich",[283,1901,1902],{},"After emission, enrichers add derived context to the event. Built-in enrichers extract data from request headers:",[292,1904,1905,1917],{},[295,1906,1907],{},[298,1908,1909,1912,1915],{},[301,1910,1911],{},"Enricher",[301,1913,1914],{},"Adds",[301,1916,902],{},[324,1918,1919,1936,1950,1967],{},[298,1920,1921,1924,1930],{},[329,1922,1923],{},"User Agent",[329,1925,1926,1929],{},[307,1927,1928],{},"userAgent"," (browser, OS, device)",[329,1931,1932,1935],{},[307,1933,1934],{},"User-Agent"," header",[298,1937,1938,1941,1947],{},[329,1939,1940],{},"Geo",[329,1942,1943,1946],{},[307,1944,1945],{},"geo"," (country, region, city)",[329,1948,1949],{},"Platform headers (Vercel, Cloudflare)",[298,1951,1952,1955,1961],{},[329,1953,1954],{},"Request Size",[329,1956,1957,1960],{},[307,1958,1959],{},"requestSize"," (request\u002Fresponse bytes)",[329,1962,1963,1966],{},[307,1964,1965],{},"Content-Length"," headers",[298,1968,1969,1972,1978],{},[329,1970,1971],{},"Trace Context",[329,1973,1974,1977],{},[307,1975,1976],{},"traceContext"," (traceId, spanId)",[329,1979,1980,1935],{},[307,1981,1982],{},"traceparent",[447,1984,1987],{"className":784,"code":1985,"filename":1986,"language":787,"meta":452,"style":452},"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",[307,1988,1989,2014,2018,2038,2063,2067,2099,2127,2133],{"__ignoreMap":452},[456,1990,1991,1993,1995,1998,2000,2003,2005,2007,2009,2012],{"class":458,"line":459},[456,1992,986],{"class":794},[456,1994,989],{"class":808},[456,1996,1997],{"class":462}," createUserAgentEnricher",[456,1999,1088],{"class":808},[456,2001,2002],{"class":462}," createGeoEnricher",[456,2004,995],{"class":808},[456,2006,998],{"class":794},[456,2008,1001],{"class":808},[456,2010,2011],{"class":827},"evlog\u002Fenrichers",[456,2013,1007],{"class":808},[456,2015,2016],{"class":458,"line":466},[456,2017,1013],{"emptyLinePlaceholder":1012},[456,2019,2020,2022,2024,2026,2028,2030,2032,2034,2036],{"class":458,"line":472},[456,2021,795],{"class":794},[456,2023,798],{"class":794},[456,2025,1395],{"class":801},[456,2027,805],{"class":462},[456,2029,805],{"class":808},[456,2031,1403],{"class":1402},[456,2033,1219],{"class":808},[456,2035,1408],{"class":1018},[456,2037,846],{"class":808},[456,2039,2040,2043,2046,2048,2050,2053,2056,2058,2060],{"class":458,"line":478},[456,2041,2042],{"class":1018},"  const",[456,2044,2045],{"class":462}," enrichers",[456,2047,1490],{"class":808},[456,2049,821],{"class":814},[456,2051,2052],{"class":801},"createUserAgentEnricher",[456,2054,2055],{"class":814},"()",[456,2057,1088],{"class":808},[456,2059,2002],{"class":801},[456,2061,2062],{"class":814},"()]\n",[456,2064,2065],{"class":458,"line":484},[456,2066,1013],{"emptyLinePlaceholder":1012},[456,2068,2069,2071,2073,2075,2077,2079,2081,2083,2085,2087,2089,2091,2093,2095,2097],{"class":458,"line":490},[456,2070,1415],{"class":462},[456,2072,1058],{"class":808},[456,2074,1420],{"class":462},[456,2076,1058],{"class":808},[456,2078,1425],{"class":801},[456,2080,805],{"class":814},[456,2082,824],{"class":808},[456,2084,1899],{"class":827},[456,2086,824],{"class":808},[456,2088,1088],{"class":808},[456,2090,1438],{"class":808},[456,2092,1441],{"class":1402},[456,2094,1219],{"class":808},[456,2096,1408],{"class":1018},[456,2098,846],{"class":808},[456,2100,2101,2104,2106,2108,2111,2114,2116,2118,2121,2123,2125],{"class":458,"line":496},[456,2102,2103],{"class":794},"    for",[456,2105,1438],{"class":814},[456,2107,1019],{"class":1018},[456,2109,2110],{"class":462}," enricher",[456,2112,2113],{"class":808}," of",[456,2115,2045],{"class":462},[456,2117,1475],{"class":814},[456,2119,2120],{"class":801},"enricher",[456,2122,805],{"class":814},[456,2124,1441],{"class":462},[456,2126,879],{"class":814},[456,2128,2129,2131],{"class":458,"line":502},[456,2130,1504],{"class":808},[456,2132,879],{"class":814},[456,2134,2135,2137],{"class":458,"line":507},[456,2136,876],{"class":808},[456,2138,879],{"class":462},[283,2140,2141,2142,2145],{},"Enrichers receive the full ",[307,2143,2144],{},"EnrichContext"," with the mutable event, request metadata, safe headers, and response info.",[762,2147,2149,2150,1219],{"id":2148},"_9-drain-evlogdrain","9. Drain (",[307,2151,2152],{},"evlog:drain",[283,2154,2155,2156,2158,2159,2162],{},"The final step sends the enriched event to your observability platform. The ",[307,2157,2152],{}," hook receives a ",[307,2160,2161],{},"DrainContext"," with the complete event:",[447,2164,2167],{"className":784,"code":2165,"filename":2166,"language":787,"meta":452,"style":452},"import { createAxiomDrain } from 'evlog\u002Faxiom'\n\nexport default defineNitroPlugin((nitroApp) => {\n  nitroApp.hooks.hook('evlog:drain', createAxiomDrain())\n})\n","server\u002Fplugins\u002Fevlog-drain.ts",[307,2168,2169,2189,2193,2213,2240],{"__ignoreMap":452},[456,2170,2171,2173,2175,2178,2180,2182,2184,2187],{"class":458,"line":459},[456,2172,986],{"class":794},[456,2174,989],{"class":808},[456,2176,2177],{"class":462}," createAxiomDrain",[456,2179,995],{"class":808},[456,2181,998],{"class":794},[456,2183,1001],{"class":808},[456,2185,2186],{"class":827},"evlog\u002Faxiom",[456,2188,1007],{"class":808},[456,2190,2191],{"class":458,"line":466},[456,2192,1013],{"emptyLinePlaceholder":1012},[456,2194,2195,2197,2199,2201,2203,2205,2207,2209,2211],{"class":458,"line":472},[456,2196,795],{"class":794},[456,2198,798],{"class":794},[456,2200,1395],{"class":801},[456,2202,805],{"class":462},[456,2204,805],{"class":808},[456,2206,1403],{"class":1402},[456,2208,1219],{"class":808},[456,2210,1408],{"class":1018},[456,2212,846],{"class":808},[456,2214,2215,2217,2219,2221,2223,2225,2227,2229,2231,2233,2235,2237],{"class":458,"line":478},[456,2216,1415],{"class":462},[456,2218,1058],{"class":808},[456,2220,1420],{"class":462},[456,2222,1058],{"class":808},[456,2224,1425],{"class":801},[456,2226,805],{"class":814},[456,2228,824],{"class":808},[456,2230,2152],{"class":827},[456,2232,824],{"class":808},[456,2234,1088],{"class":808},[456,2236,2177],{"class":801},[456,2238,2239],{"class":814},"())\n",[456,2241,2242,2244],{"class":458,"line":484},[456,2243,876],{"class":808},[456,2245,879],{"class":462},[283,2247,2248,2249,2252],{},"On platforms with ",[307,2250,2251],{},"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.",[287,2254,2256],{"id":2255},"hook-execution-order","Hook Execution Order",[292,2258,2259,2275],{},[295,2260,2261],{},[298,2262,2263,2266,2269,2272],{},[301,2264,2265],{},"Order",[301,2267,2268],{},"Hook",[301,2270,2271],{},"When",[301,2273,2274],{},"Purpose",[324,2276,2277,2292,2307],{},[298,2278,2279,2282,2286,2289],{},[329,2280,2281],{},"1",[329,2283,2284],{},[307,2285,1254],{},[329,2287,2288],{},"After request ends, before sampling",[329,2290,2291],{},"Force-keep events based on outcome",[298,2293,2294,2297,2301,2304],{},[329,2295,2296],{},"2",[329,2298,2299],{},[307,2300,1899],{},[329,2302,2303],{},"After emit, before drain",[329,2305,2306],{},"Add derived context to the event",[298,2308,2309,2312,2316,2319],{},[329,2310,2311],{},"3",[329,2313,2314],{},[307,2315,2152],{},[329,2317,2318],{},"After enrichment",[329,2320,2321],{},"Send event to external services",[287,2323,2325],{"id":2324},"error-vs-success-path","Error vs Success Path",[283,2327,2328,2329,2332],{},"Both paths converge at the same emit\u002Fenrich\u002Fdrain pipeline. The only difference is ",[1263,2330,2331],{},"when"," the emit is triggered:",[292,2334,2335,2347],{},[295,2336,2337],{},[298,2338,2339,2341,2344],{},[301,2340],{},[301,2342,2343],{},"Success",[301,2345,2346],{},"Error",[324,2348,2349,2369,2387,2403,2424],{},[298,2350,2351,2356,2365],{},[329,2352,2353],{},[332,2354,2355],{},"Trigger",[329,2357,2358,316,2361,2364],{},[307,2359,2360],{},"afterResponse",[307,2362,2363],{},"response"," hook",[329,2366,2367,2364],{},[307,2368,1194],{},[298,2370,2371,2375,2383],{},[329,2372,2373],{},[332,2374,1233],{},[329,2376,2377,2379,2380,2382],{},[307,2378,1244],{}," (or ",[307,2381,1240],{}," if status >= 400)",[329,2384,2385],{},[307,2386,1194],{},[298,2388,2389,2394,2397],{},[329,2390,2391],{},[332,2392,2393],{},"Status",[329,2395,2396],{},"From response",[329,2398,2399,2400,2402],{},"From error's ",[307,2401,1215],{}," field (default 500)",[298,2404,2405,2410,2413],{},[329,2406,2407],{},[332,2408,2409],{},"Error context",[329,2411,2412],{},"None",[329,2414,2415,2417,2418,918,2421],{},[307,2416,1194],{}," field with message, stack, ",[307,2419,2420],{},"why",[307,2422,2423],{},"fix",[298,2425,2426,2431,2438],{},[329,2427,2428],{},[332,2429,2430],{},"Double-emit guard",[329,2432,2433,2434,2437],{},"Checks ",[307,2435,2436],{},"_evlogEmitted"," flag",[329,2439,2440,2441],{},"Sets ",[307,2442,2443],{},"_evlogEmitted = true",[287,2445,2447],{"id":2446},"simple-logging-pipeline","Simple Logging Pipeline",[283,2449,2450,2451,2453],{},"When using the ",[307,2452,309],{}," singleton, the pipeline is shorter:",[2455,2456,2457,2469,2474],"ol",{},[1207,2458,2459,2462,2463,343,2466],{},[332,2460,2461],{},"Call",": ",[307,2464,2465],{},"log.info({ action: 'deploy' })",[307,2467,2468],{},"log.info('tag', 'message')",[1207,2470,2471,2473],{},[332,2472,380],{},": The event is built and printed immediately",[1207,2475,2476,2478,2479,2482,2483,2486],{},[332,2477,429],{},": If a global ",[307,2480,2481],{},"drain"," was configured via ",[307,2484,2485],{},"initLogger()",", the event is sent to external services",[283,2488,2489,2490,2492,2493,2496],{},"Tagged logs (",[307,2491,2468],{},") are console-only in pretty mode. Object-form logs (",[307,2494,2495],{},"log.info({ ... })",") always flow through the drain pipeline.",[287,2498,2500],{"id":2499},"standalone-wide-event-pipeline","Standalone Wide Event Pipeline",[283,2502,2503,2504,2507],{},"When using ",[307,2505,2506],{},"createLogger()"," outside a framework:",[2455,2509,2510,2517,2533,2541,2549],{},[1207,2511,2512,2462,2514],{},[332,2513,334],{},[307,2515,2516],{},"createLogger({ jobId: 'sync-001' })",[1207,2518,2519,2462,2521,918,2523,918,2526,918,2529,2532],{},[332,2520,356],{},[307,2522,364],{},[307,2524,2525],{},"log.info()",[307,2527,2528],{},"log.warn()",[307,2530,2531],{},"log.error()"," over the operation",[1207,2534,2535,2537,2538,2540],{},[332,2536,380],{},": Manual ",[307,2539,389],{}," call",[1207,2542,2543,2545,2546],{},[332,2544,399],{},": Head sampling applies based on computed level. Tail sampling via ",[307,2547,2548],{},"initLogger({ sampling: { keep: [...] } })",[1207,2550,2551,2478,2553,2555],{},[332,2552,429],{},[307,2554,2481],{}," was configured, the event is sent",[447,2557,2560],{"className":784,"code":2558,"filename":2559,"language":787,"meta":452,"style":452},"import { initLogger, createLogger } from 'evlog'\nimport { createAxiomDrain } from 'evlog\u002Faxiom'\n\ninitLogger({\n  env: { service: 'worker' },\n  drain: createAxiomDrain(),\n  sampling: { rates: { info: 10 } },\n})\n\nconst log = createLogger({ task: 'migrate' })\nlog.set({ records: 500, status: 'complete' })\nlog.emit()\n","scripts\u002Fmigrate.ts",[307,2561,2562,2586,2604,2608,2617,2640,2653,2678,2684,2688,2718,2755],{"__ignoreMap":452},[456,2563,2564,2566,2568,2571,2573,2576,2578,2580,2582,2584],{"class":458,"line":459},[456,2565,986],{"class":794},[456,2567,989],{"class":808},[456,2569,2570],{"class":462}," initLogger",[456,2572,1088],{"class":808},[456,2574,2575],{"class":462}," createLogger",[456,2577,995],{"class":808},[456,2579,998],{"class":794},[456,2581,1001],{"class":808},[456,2583,1004],{"class":827},[456,2585,1007],{"class":808},[456,2587,2588,2590,2592,2594,2596,2598,2600,2602],{"class":458,"line":466},[456,2589,986],{"class":794},[456,2591,989],{"class":808},[456,2593,2177],{"class":462},[456,2595,995],{"class":808},[456,2597,998],{"class":794},[456,2599,1001],{"class":808},[456,2601,2186],{"class":827},[456,2603,1007],{"class":808},[456,2605,2606],{"class":458,"line":472},[456,2607,1013],{"emptyLinePlaceholder":1012},[456,2609,2610,2613,2615],{"class":458,"line":478},[456,2611,2612],{"class":801},"initLogger",[456,2614,805],{"class":462},[456,2616,809],{"class":808},[456,2618,2619,2622,2624,2626,2629,2631,2633,2636,2638],{"class":458,"line":484},[456,2620,2621],{"class":814},"  env",[456,2623,818],{"class":808},[456,2625,989],{"class":808},[456,2627,2628],{"class":814}," service",[456,2630,818],{"class":808},[456,2632,1001],{"class":808},[456,2634,2635],{"class":827},"worker",[456,2637,824],{"class":808},[456,2639,1597],{"class":808},[456,2641,2642,2645,2647,2649,2651],{"class":458,"line":490},[456,2643,2644],{"class":814},"  drain",[456,2646,818],{"class":808},[456,2648,2177],{"class":801},[456,2650,2055],{"class":462},[456,2652,836],{"class":808},[456,2654,2655,2657,2659,2661,2664,2666,2668,2670,2672,2674,2676],{"class":458,"line":496},[456,2656,1285],{"class":814},[456,2658,818],{"class":808},[456,2660,989],{"class":808},[456,2662,2663],{"class":814}," rates",[456,2665,818],{"class":808},[456,2667,989],{"class":808},[456,2669,1569],{"class":814},[456,2671,818],{"class":808},[456,2673,1574],{"class":1312},[456,2675,995],{"class":808},[456,2677,1597],{"class":808},[456,2679,2680,2682],{"class":458,"line":502},[456,2681,876],{"class":808},[456,2683,879],{"class":462},[456,2685,2686],{"class":458,"line":507},[456,2687,1013],{"emptyLinePlaceholder":1012},[456,2689,2690,2692,2694,2696,2698,2700,2702,2705,2707,2709,2712,2714,2716],{"class":458,"line":513},[456,2691,1019],{"class":1018},[456,2693,1022],{"class":462},[456,2695,1025],{"class":808},[456,2697,2575],{"class":801},[456,2699,805],{"class":462},[456,2701,1066],{"class":808},[456,2703,2704],{"class":814}," task",[456,2706,818],{"class":808},[456,2708,1001],{"class":808},[456,2710,2711],{"class":827},"migrate",[456,2713,824],{"class":808},[456,2715,995],{"class":808},[456,2717,879],{"class":462},[456,2719,2720,2722,2724,2726,2728,2730,2733,2735,2738,2740,2742,2744,2746,2749,2751,2753],{"class":458,"line":519},[456,2721,309],{"class":462},[456,2723,1058],{"class":808},[456,2725,1061],{"class":801},[456,2727,805],{"class":462},[456,2729,1066],{"class":808},[456,2731,2732],{"class":814}," records",[456,2734,818],{"class":808},[456,2736,2737],{"class":1312}," 500",[456,2739,1088],{"class":808},[456,2741,1327],{"class":814},[456,2743,818],{"class":808},[456,2745,1001],{"class":808},[456,2747,2748],{"class":827},"complete",[456,2750,824],{"class":808},[456,2752,995],{"class":808},[456,2754,879],{"class":462},[456,2756,2757,2759,2761,2764],{"class":458,"line":525},[456,2758,309],{"class":462},[456,2760,1058],{"class":808},[456,2762,2763],{"class":801},"emit",[456,2765,2766],{"class":462},"()\n",[287,2768,2770],{"id":2769},"next-steps","Next Steps",[1204,2772,2773,2779,2784,2789],{},[1207,2774,2775,2778],{},[2776,2777,46],"a",{"href":47}," - Design effective wide events",[1207,2780,2781,2783],{},[2776,2782,81],{"href":82}," - Configure head and tail sampling",[1207,2785,2786,2788],{},[2776,2787,189],{"href":194}," - Send events to external platforms",[1207,2790,2791,2793],{},[2776,2792,248],{"href":253}," - Add derived context automatically",[2795,2796,2797],"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":452,"searchDepth":466,"depth":466,"links":2799},[2800,2801,2802,2816,2817,2818,2819,2820],{"id":289,"depth":466,"text":290},{"id":438,"depth":466,"text":439},{"id":759,"depth":466,"text":760,"children":2803},[2804,2805,2806,2807,2808,2810,2811,2812,2814],{"id":764,"depth":472,"text":765},{"id":882,"depth":472,"text":883},{"id":968,"depth":472,"text":969},{"id":1198,"depth":472,"text":1199},{"id":1250,"depth":472,"text":2809},"5. Tail Sampling (evlog:emit:keep)",{"id":1525,"depth":472,"text":1526},{"id":1634,"depth":472,"text":1635},{"id":1895,"depth":472,"text":2813},"8. Enrich (evlog:enrich)",{"id":2148,"depth":472,"text":2815},"9. Drain (evlog:drain)",{"id":2255,"depth":466,"text":2256},{"id":2324,"depth":466,"text":2325},{"id":2446,"depth":466,"text":2447},{"id":2499,"depth":466,"text":2500},{"id":2769,"depth":466,"text":2770},"Understand the full lifecycle of an evlog event, from creation to drain. Covers all three modes (simple logging, wide events, request logging), sampling, enrichment, and delivery.","md",[2824,2827],{"label":46,"icon":49,"to":47,"color":2825,"variant":2826},"neutral","subtle",{"label":81,"icon":84,"to":82,"color":2825,"variant":2826},{},{"icon":74},{"title":71,"description":2821},"M7UZN0ZzgBsZRqAv3QX0co9A2JK53gzEQ-EmkLbUr70",[2833,2835],{"title":61,"path":62,"stem":63,"description":2834,"icon":64,"children":-1},"Capture token usage, tool calls, model info, and streaming metrics from the Vercel AI SDK into wide events. Wrap your model and get full AI observability.",{"title":76,"path":77,"stem":78,"description":2836,"icon":79,"children":-1},"Complete reference for all evlog configuration options including global logger settings, middleware options, environment context, and framework-specific overrides.",1775317374498]