[{"data":1,"prerenderedAt":1309},["ShallowReactive",2],{"navigation_docs":3,"-logging-audit-pipeline":421,"-logging-audit-pipeline-surround":1304},[4,35,159,201,289,318,405],{"title":5,"path":6,"stem":7,"children":8,"page":34},"Getting Started","\u002Fgetting-started","1.getting-started",[9,14,19,24,29],{"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",{"title":30,"path":31,"stem":32,"icon":33},"vs Other Loggers","\u002Fgetting-started\u002Fvs-other-loggers","1.getting-started\u002F5.vs-other-loggers","i-lucide-scale",false,{"title":36,"path":37,"stem":38,"children":39,"page":34},"Logging","\u002Flogging","2.logging",[40,45,50,55,60,65,70,99,127],{"title":41,"path":42,"stem":43,"icon":44},"Overview","\u002Flogging\u002Foverview","2.logging\u002F0.overview","i-lucide-list",{"title":46,"path":47,"stem":48,"icon":49},"Simple Logging","\u002Flogging\u002Fsimple-logging","2.logging\u002F1.simple-logging","i-lucide-terminal",{"title":51,"path":52,"stem":53,"icon":54},"Wide Events","\u002Flogging\u002Fwide-events","2.logging\u002F2.wide-events","i-lucide-layers",{"title":56,"path":57,"stem":58,"icon":59},"Structured Errors","\u002Flogging\u002Fstructured-errors","2.logging\u002F3.structured-errors","i-lucide-shield-alert",{"title":61,"path":62,"stem":63,"icon":64},"Catalogs","\u002Flogging\u002Fcatalogs","2.logging\u002F4.catalogs","i-lucide-book-open",{"title":66,"path":67,"stem":68,"icon":69},"Client Logging","\u002Flogging\u002Fclient-logging","2.logging\u002F5.client-logging","i-lucide-monitor",{"title":71,"icon":72,"path":73,"stem":74,"children":75,"page":34},"AI SDK","i-simple-icons-vercel","\u002Flogging\u002Fai-sdk","2.logging\u002F6.ai-sdk",[76,79,84,89,94],{"title":41,"path":77,"stem":78,"icon":44},"\u002Flogging\u002Fai-sdk\u002Foverview","2.logging\u002F6.ai-sdk\u002F01.overview",{"title":80,"path":81,"stem":82,"icon":83},"Usage","\u002Flogging\u002Fai-sdk\u002Fusage","2.logging\u002F6.ai-sdk\u002F02.usage","i-lucide-code",{"title":85,"path":86,"stem":87,"icon":88},"Options","\u002Flogging\u002Fai-sdk\u002Foptions","2.logging\u002F6.ai-sdk\u002F03.options","i-lucide-sliders",{"title":90,"path":91,"stem":92,"icon":93},"Metadata","\u002Flogging\u002Fai-sdk\u002Fmetadata","2.logging\u002F6.ai-sdk\u002F04.metadata","i-lucide-database",{"title":95,"path":96,"stem":97,"icon":98},"Telemetry","\u002Flogging\u002Fai-sdk\u002Ftelemetry","2.logging\u002F6.ai-sdk\u002F05.telemetry","i-lucide-activity",{"title":100,"icon":101,"path":102,"stem":103,"children":104,"page":34},"Better Auth","i-simple-icons-betterauth","\u002Flogging\u002Fbetter-auth","2.logging\u002F7.better-auth",[105,108,113,118,122],{"title":41,"path":106,"stem":107,"icon":44},"\u002Flogging\u002Fbetter-auth\u002Foverview","2.logging\u002F7.better-auth\u002F01.overview",{"title":109,"path":110,"stem":111,"icon":112},"Identify User","\u002Flogging\u002Fbetter-auth\u002Fidentify-user","2.logging\u002F7.better-auth\u002F02.identify-user","i-lucide-user-check",{"title":114,"path":115,"stem":116,"icon":117},"Middleware","\u002Flogging\u002Fbetter-auth\u002Fmiddleware","2.logging\u002F7.better-auth\u002F03.middleware","i-lucide-shield",{"title":119,"path":120,"stem":121,"icon":69},"Client Sync","\u002Flogging\u002Fbetter-auth\u002Fclient-sync","2.logging\u002F7.better-auth\u002F04.client-sync",{"title":123,"path":124,"stem":125,"icon":126},"Performance","\u002Flogging\u002Fbetter-auth\u002Fperformance","2.logging\u002F7.better-auth\u002F05.performance","i-lucide-gauge",{"title":128,"icon":129,"path":130,"stem":131,"children":132,"page":34},"Audit Logs","i-lucide-shield-check","\u002Flogging\u002Faudit","2.logging\u002F8.audit",[133,136,141,146,151,155],{"title":41,"path":134,"stem":135,"icon":44},"\u002Flogging\u002Faudit\u002Foverview","2.logging\u002F8.audit\u002F01.overview",{"title":137,"path":138,"stem":139,"icon":140},"Schema","\u002Flogging\u002Faudit\u002Fschema","2.logging\u002F8.audit\u002F02.schema","i-lucide-file-text",{"title":142,"path":143,"stem":144,"icon":145},"Recording","\u002Flogging\u002Faudit\u002Frecording","2.logging\u002F8.audit\u002F03.recording","i-lucide-pen-line",{"title":147,"path":148,"stem":149,"icon":150},"Drains","\u002Flogging\u002Faudit\u002Fpipeline","2.logging\u002F8.audit\u002F04.pipeline","i-lucide-link",{"title":152,"path":153,"stem":154,"icon":129},"Compliance","\u002Flogging\u002Faudit\u002Fcompliance","2.logging\u002F8.audit\u002F05.compliance",{"title":156,"path":157,"stem":158,"icon":64},"Recipes","\u002Flogging\u002Faudit\u002Frecipes","2.logging\u002F8.audit\u002F06.recipes",{"title":160,"path":161,"stem":162,"children":163,"page":34},"Core Concepts","\u002Fcore-concepts","3.core-concepts",[164,169,174,179,184,188,191,196],{"title":165,"path":166,"stem":167,"icon":168},"Lifecycle","\u002Fcore-concepts\u002Flifecycle","3.core-concepts\u002F0.lifecycle","i-lucide-arrow-right-left",{"title":170,"path":171,"stem":172,"icon":173},"Configuration","\u002Fcore-concepts\u002Fconfiguration","3.core-concepts\u002F1.configuration","i-lucide-settings",{"title":175,"path":176,"stem":177,"icon":178},"Sampling","\u002Fcore-concepts\u002Fsampling","3.core-concepts\u002F2.sampling","i-lucide-filter",{"title":180,"path":181,"stem":182,"icon":183},"Typed Fields","\u002Fcore-concepts\u002Ftyped-fields","3.core-concepts\u002F3.typed-fields","i-simple-icons-typescript",{"title":185,"path":186,"stem":187,"icon":129},"Best Practices","\u002Fcore-concepts\u002Fbest-practices","3.core-concepts\u002F4.best-practices",{"title":123,"path":189,"stem":190,"icon":126},"\u002Fcore-concepts\u002Fperformance","3.core-concepts\u002F5.performance",{"title":192,"path":193,"stem":194,"icon":195},"Vite Plugin","\u002Fcore-concepts\u002Fvite-plugin","3.core-concepts\u002F6.vite-plugin","i-custom-vite",{"title":197,"path":198,"stem":199,"icon":200},"Auto-Redaction","\u002Fcore-concepts\u002Fredaction","3.core-concepts\u002F7.redaction","i-lucide-eye-off",{"title":202,"path":203,"stem":204,"children":205,"page":34},"Frameworks","\u002Fframeworks","4.frameworks",[206,210,215,220,225,230,235,240,245,250,255,260,265,270,274,279,284],{"title":41,"path":207,"stem":208,"icon":209},"\u002Fframeworks\u002Foverview","4.frameworks\u002F00.overview","i-lucide-layout-grid",{"title":211,"path":212,"stem":213,"icon":214},"Nuxt","\u002Fframeworks\u002Fnuxt","4.frameworks\u002F01.nuxt","i-simple-icons-nuxtdotjs",{"title":216,"path":217,"stem":218,"icon":219},"Next.js","\u002Fframeworks\u002Fnextjs","4.frameworks\u002F02.nextjs","i-simple-icons-nextdotjs",{"title":221,"path":222,"stem":223,"icon":224},"SvelteKit","\u002Fframeworks\u002Fsveltekit","4.frameworks\u002F03.sveltekit","i-simple-icons-svelte",{"title":226,"path":227,"stem":228,"icon":229},"Nitro","\u002Fframeworks\u002Fnitro","4.frameworks\u002F04.nitro","i-custom-nitro",{"title":231,"path":232,"stem":233,"icon":234},"TanStack Start","\u002Fframeworks\u002Ftanstack-start","4.frameworks\u002F05.tanstack-start","i-custom-tanstack",{"title":236,"path":237,"stem":238,"icon":239},"NestJS","\u002Fframeworks\u002Fnestjs","4.frameworks\u002F06.nestjs","i-simple-icons-nestjs",{"title":241,"path":242,"stem":243,"icon":244},"Express","\u002Fframeworks\u002Fexpress","4.frameworks\u002F07.express","i-simple-icons-express",{"title":246,"path":247,"stem":248,"icon":249},"Hono","\u002Fframeworks\u002Fhono","4.frameworks\u002F08.hono","i-simple-icons-hono",{"title":251,"path":252,"stem":253,"icon":254},"Fastify","\u002Fframeworks\u002Ffastify","4.frameworks\u002F09.fastify","i-simple-icons-fastify",{"title":256,"path":257,"stem":258,"icon":259},"Elysia","\u002Fframeworks\u002Felysia","4.frameworks\u002F10.elysia","i-custom-elysia",{"title":261,"path":262,"stem":263,"icon":264},"React Router","\u002Fframeworks\u002Freact-router","4.frameworks\u002F11.react-router","i-custom-reactrouter",{"title":266,"path":267,"stem":268,"icon":269},"Cloudflare Workers","\u002Fframeworks\u002Fcloudflare-workers","4.frameworks\u002F12.cloudflare-workers","i-simple-icons-cloudflare",{"title":271,"path":272,"stem":273,"icon":183},"Standalone","\u002Fframeworks\u002Fstandalone","4.frameworks\u002F13.standalone",{"title":275,"path":276,"stem":277,"icon":278},"Astro","\u002Fframeworks\u002Fastro","4.frameworks\u002F14.astro","i-simple-icons-astro",{"title":280,"path":281,"stem":282,"icon":283},"AWS Lambda","\u002Fframeworks\u002Faws-lambda","4.frameworks\u002F16.aws-lambda","i-custom-lambda",{"title":285,"path":286,"stem":287,"icon":288},"Custom Integration","\u002Fframeworks\u002Fcustom-integration","4.frameworks\u002F17.custom-integration","i-lucide-puzzle",{"title":290,"path":291,"stem":292,"children":293,"page":34},"Build on top","\u002Fbuild-on-top","5.build-on-top",[294,299,304,309,314],{"title":295,"path":296,"stem":297,"icon":298},"Identity headers","\u002Fbuild-on-top\u002Fidentity-headers","5.build-on-top\u002F1.identity-headers","i-lucide-fingerprint",{"title":300,"path":301,"stem":302,"icon":303},"Stream API","\u002Fbuild-on-top\u002Fstream-api","5.build-on-top\u002F2.stream-api","i-lucide-radio-tower",{"title":305,"path":306,"stem":307,"icon":308},"SSE bridge","\u002Fbuild-on-top\u002Fsse-bridge","5.build-on-top\u002F3.sse-bridge","i-lucide-wifi",{"title":310,"path":311,"stem":312,"icon":313},"FS reader","\u002Fbuild-on-top\u002Ffs-reader","5.build-on-top\u002F4.fs-reader","i-lucide-folder-search",{"title":156,"path":315,"stem":316,"icon":317},"\u002Fbuild-on-top\u002Frecipes","5.build-on-top\u002F4.recipes","i-lucide-chef-hat",{"title":319,"path":320,"stem":321,"children":322,"page":34},"Adapters","\u002Fadapters","6.adapters",[323,326,366,381],{"title":41,"path":324,"stem":325,"icon":44},"\u002Fadapters\u002Foverview","6.adapters\u002F01.overview",{"title":327,"path":328,"stem":329,"children":330,"page":34},"Cloud destinations","\u002Fadapters\u002Fcloud","6.adapters\u002F02.cloud",[331,336,341,346,351,356,361],{"title":332,"path":333,"stem":334,"icon":335},"Axiom","\u002Fadapters\u002Fcloud\u002Faxiom","6.adapters\u002F02.cloud\u002F01.axiom","i-custom-axiom",{"title":337,"path":338,"stem":339,"icon":340},"OTLP","\u002Fadapters\u002Fcloud\u002Fotlp","6.adapters\u002F02.cloud\u002F02.otlp","i-simple-icons-opentelemetry",{"title":342,"path":343,"stem":344,"icon":345},"PostHog","\u002Fadapters\u002Fcloud\u002Fposthog","6.adapters\u002F02.cloud\u002F03.posthog","i-simple-icons-posthog",{"title":347,"path":348,"stem":349,"icon":350},"Sentry","\u002Fadapters\u002Fcloud\u002Fsentry","6.adapters\u002F02.cloud\u002F04.sentry","i-simple-icons-sentry",{"title":352,"path":353,"stem":354,"icon":355},"Better Stack","\u002Fadapters\u002Fcloud\u002Fbetter-stack","6.adapters\u002F02.cloud\u002F05.better-stack","i-simple-icons-betterstack",{"title":357,"path":358,"stem":359,"icon":360},"Datadog","\u002Fadapters\u002Fcloud\u002Fdatadog","6.adapters\u002F02.cloud\u002F06.datadog","i-simple-icons-datadog",{"title":362,"path":363,"stem":364,"icon":365},"HyperDX","\u002Fadapters\u002Fcloud\u002Fhyperdx","6.adapters\u002F02.cloud\u002F07.hyperdx","i-custom-hyperdx",{"title":367,"path":368,"stem":369,"children":370,"page":34},"Self-hosted","\u002Fadapters\u002Fself-hosted","6.adapters\u002F03.self-hosted",[371,376],{"title":372,"path":373,"stem":374,"icon":375},"File System","\u002Fadapters\u002Fself-hosted\u002Ffs","6.adapters\u002F03.self-hosted\u002F01.fs","i-lucide-hard-drive",{"title":377,"path":378,"stem":379,"icon":380},"NuxtHub","\u002Fadapters\u002Fself-hosted\u002Fnuxthub","6.adapters\u002F03.self-hosted\u002F02.nuxthub","i-simple-icons-nuxt",{"title":382,"path":383,"stem":384,"children":385,"page":34},"Building blocks","\u002Fadapters\u002Fbuilding-blocks","6.adapters\u002F04.building-blocks",[386,391,396,400],{"title":387,"path":388,"stem":389,"icon":390},"Pipeline","\u002Fadapters\u002Fbuilding-blocks\u002Fpipeline","6.adapters\u002F04.building-blocks\u002F01.pipeline","i-lucide-workflow",{"title":392,"path":393,"stem":394,"icon":395},"HTTP","\u002Fadapters\u002Fbuilding-blocks\u002Fhttp","6.adapters\u002F04.building-blocks\u002F02.http","i-lucide-globe",{"title":397,"path":398,"stem":399,"icon":83},"Custom Adapters","\u002Fadapters\u002Fbuilding-blocks\u002Fcustom","6.adapters\u002F04.building-blocks\u002F03.custom",{"title":401,"path":402,"stem":403,"icon":404},"Toolkit","\u002Fadapters\u002Fbuilding-blocks\u002Ftoolkit","6.adapters\u002F04.building-blocks\u002F04.toolkit","i-lucide-blocks",{"title":406,"path":407,"stem":408,"children":409,"page":34},"Enrichers","\u002Fenrichers","7.enrichers",[410,413,417],{"title":41,"path":411,"stem":412,"icon":28},"\u002Fenrichers\u002Foverview","7.enrichers\u002F1.overview",{"title":414,"path":415,"stem":416,"icon":288},"Built-in","\u002Fenrichers\u002Fbuilt-in","7.enrichers\u002F2.built-in",{"title":418,"path":419,"stem":420,"icon":83},"Custom","\u002Fenrichers\u002Fcustom","7.enrichers\u002F3.custom",{"id":422,"title":423,"body":424,"description":1293,"extension":1294,"links":1295,"meta":1300,"navigation":1301,"path":148,"seo":1302,"stem":149,"__hash__":1303},"docs\u002F2.logging\u002F8.audit\u002F04.pipeline.md","Drains & Integrity",{"type":425,"value":426,"toc":1285},"minimark",[427,444,451,460,547,550,673,691,697,717,731,868,875,927,933,938,944,1001,1018,1023,1026,1101,1105,1108,1257,1263,1266,1281],[428,429,430,431,435,436,439,440,443],"p",{},"Three building blocks: ",[432,433,434],"code",{},"auditEnricher"," fills context, ",[432,437,438],{},"auditOnly"," routes audits to a dedicated drain, and ",[432,441,442],{},"signed"," adds tamper-evident integrity. Each is opt-in and replaceable.",[445,446,448],"h2",{"id":447},"auditenricher",[432,449,450],{},"auditEnricher()",[428,452,453,455,456,459],{},[432,454,450],{}," populates ",[432,457,458],{},"event.audit.context.{requestId, traceId, ip, userAgent, tenantId}",". Skip it and ship a custom enricher if your strategy differs.",[461,462,468],"pre",{"className":463,"code":464,"filename":465,"language":466,"meta":467,"style":467},"language-typescript shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","import { auditEnricher } from 'evlog'\n\nnitro.hooks.hook('evlog:enrich', auditEnricher())\n","server\u002Fplugins\u002Fevlog.ts","typescript","",[432,469,470,503,510],{"__ignoreMap":467},[471,472,475,479,483,487,490,493,496,500],"span",{"class":473,"line":474},"line",1,[471,476,478],{"class":477},"s7zQu","import",[471,480,482],{"class":481},"sMK4o"," {",[471,484,486],{"class":485},"sTEyZ"," auditEnricher",[471,488,489],{"class":481}," }",[471,491,492],{"class":477}," from",[471,494,495],{"class":481}," '",[471,497,499],{"class":498},"sfazB","evlog",[471,501,502],{"class":481},"'\n",[471,504,506],{"class":473,"line":505},2,[471,507,509],{"emptyLinePlaceholder":508},true,"\n",[471,511,513,516,519,522,524,528,531,534,537,539,542,544],{"class":473,"line":512},3,[471,514,515],{"class":485},"nitro",[471,517,518],{"class":481},".",[471,520,521],{"class":485},"hooks",[471,523,518],{"class":481},[471,525,527],{"class":526},"s2Zo4","hook",[471,529,530],{"class":485},"(",[471,532,533],{"class":481},"'",[471,535,536],{"class":498},"evlog:enrich",[471,538,533],{"class":481},[471,540,541],{"class":481},",",[471,543,486],{"class":526},[471,545,546],{"class":485},"())\n",[428,548,549],{},"For multi-tenant apps and custom session bridges, pass options:",[461,551,553],{"className":463,"code":552,"language":466,"meta":467,"style":467},"nitro.hooks.hook('evlog:enrich', auditEnricher({\n  tenantId: ctx => ctx.event.tenant as string | undefined,\n  bridge: { getSession: async ctx => readSessionActor(ctx.headers) },\n}))\n",[432,554,555,584,628,664],{"__ignoreMap":467},[471,556,557,559,561,563,565,567,569,571,573,575,577,579,581],{"class":473,"line":474},[471,558,515],{"class":485},[471,560,518],{"class":481},[471,562,521],{"class":485},[471,564,518],{"class":481},[471,566,527],{"class":526},[471,568,530],{"class":485},[471,570,533],{"class":481},[471,572,536],{"class":498},[471,574,533],{"class":481},[471,576,541],{"class":481},[471,578,486],{"class":526},[471,580,530],{"class":485},[471,582,583],{"class":481},"{\n",[471,585,586,589,592,596,600,602,604,607,609,612,615,619,622,625],{"class":473,"line":505},[471,587,588],{"class":526},"  tenantId",[471,590,591],{"class":481},":",[471,593,595],{"class":594},"sHdIc"," ctx",[471,597,599],{"class":598},"spNyl"," =>",[471,601,595],{"class":485},[471,603,518],{"class":481},[471,605,606],{"class":485},"event",[471,608,518],{"class":481},[471,610,611],{"class":485},"tenant ",[471,613,614],{"class":477},"as",[471,616,618],{"class":617},"sBMFI"," string",[471,620,621],{"class":481}," |",[471,623,624],{"class":617}," undefined",[471,626,627],{"class":481},",\n",[471,629,630,634,636,638,641,643,646,648,650,653,656,658,661],{"class":473,"line":512},[471,631,633],{"class":632},"swJcz","  bridge",[471,635,591],{"class":481},[471,637,482],{"class":481},[471,639,640],{"class":526}," getSession",[471,642,591],{"class":481},[471,644,645],{"class":598}," async",[471,647,595],{"class":594},[471,649,599],{"class":598},[471,651,652],{"class":526}," readSessionActor",[471,654,655],{"class":485},"(ctx",[471,657,518],{"class":481},[471,659,660],{"class":485},"headers) ",[471,662,663],{"class":481},"},\n",[471,665,667,670],{"class":473,"line":666},4,[471,668,669],{"class":481},"}",[471,671,672],{"class":485},"))\n",[428,674,675,676,678,679,682,683,686,687,690],{},"Without ",[432,677,434],{},", ",[432,680,681],{},"audit.context"," stays empty — auditors and incident responders need at least ",[432,684,685],{},"requestId"," and ",[432,688,689],{},"ip"," to triangulate a recorded action.",[445,692,694],{"id":693},"auditonly",[432,695,696],{},"auditOnly()",[698,699,700,704,705,708,709,712,713,716],"tip",{},[701,702,703],"strong",{},"Why filter audits to a separate sink?"," Three reasons: ",[701,706,707],{},"cost"," (audit volume is tiny next to product telemetry — keep them separate so retention costs don't explode), ",[701,710,711],{},"permissions"," (the audit dataset should be read-only for engineers and write-only for the app), and ",[701,714,715],{},"retention"," (audits often live 7+ years; product logs rarely live more than 90 days).",[428,718,719,722,723,726,727,730],{},[432,720,721],{},"auditOnly(drain)"," only forwards events with an ",[432,724,725],{},"audit"," field. Compose with ",[701,728,729],{},"any"," drain:",[461,732,734],{"className":463,"code":733,"language":466,"meta":467,"style":467},"import { auditOnly } from 'evlog'\nimport { createAxiomDrain } from 'evlog\u002Faxiom'\n\n\u002F\u002F Send audits to a dedicated Axiom dataset:\nnitro.hooks.hook('evlog:drain', auditOnly(\n  createAxiomDrain({ dataset: 'audit', token: process.env.AXIOM_AUDIT_TOKEN }),\n))\n",[432,735,736,755,775,779,785,814,863],{"__ignoreMap":467},[471,737,738,740,742,745,747,749,751,753],{"class":473,"line":474},[471,739,478],{"class":477},[471,741,482],{"class":481},[471,743,744],{"class":485}," auditOnly",[471,746,489],{"class":481},[471,748,492],{"class":477},[471,750,495],{"class":481},[471,752,499],{"class":498},[471,754,502],{"class":481},[471,756,757,759,761,764,766,768,770,773],{"class":473,"line":505},[471,758,478],{"class":477},[471,760,482],{"class":481},[471,762,763],{"class":485}," createAxiomDrain",[471,765,489],{"class":481},[471,767,492],{"class":477},[471,769,495],{"class":481},[471,771,772],{"class":498},"evlog\u002Faxiom",[471,774,502],{"class":481},[471,776,777],{"class":473,"line":512},[471,778,509],{"emptyLinePlaceholder":508},[471,780,781],{"class":473,"line":666},[471,782,784],{"class":783},"sHwdD","\u002F\u002F Send audits to a dedicated Axiom dataset:\n",[471,786,788,790,792,794,796,798,800,802,805,807,809,811],{"class":473,"line":787},5,[471,789,515],{"class":485},[471,791,518],{"class":481},[471,793,521],{"class":485},[471,795,518],{"class":481},[471,797,527],{"class":526},[471,799,530],{"class":485},[471,801,533],{"class":481},[471,803,804],{"class":498},"evlog:drain",[471,806,533],{"class":481},[471,808,541],{"class":481},[471,810,744],{"class":526},[471,812,813],{"class":485},"(\n",[471,815,817,820,822,825,828,830,832,834,836,838,841,843,846,848,851,853,856,858,861],{"class":473,"line":816},6,[471,818,819],{"class":526},"  createAxiomDrain",[471,821,530],{"class":485},[471,823,824],{"class":481},"{",[471,826,827],{"class":632}," dataset",[471,829,591],{"class":481},[471,831,495],{"class":481},[471,833,725],{"class":498},[471,835,533],{"class":481},[471,837,541],{"class":481},[471,839,840],{"class":632}," token",[471,842,591],{"class":481},[471,844,845],{"class":485}," process",[471,847,518],{"class":481},[471,849,850],{"class":485},"env",[471,852,518],{"class":481},[471,854,855],{"class":485},"AXIOM_AUDIT_TOKEN ",[471,857,669],{"class":481},[471,859,860],{"class":485},")",[471,862,627],{"class":481},[471,864,866],{"class":473,"line":865},7,[471,867,672],{"class":485},[428,869,870,871,874],{},"Set ",[432,872,873],{},"await: true"," to make audit writes synchronous (no fire-and-forget for audits — crash-safe by default):",[461,876,878],{"className":463,"code":877,"language":466,"meta":467,"style":467},"auditOnly(createFsDrain({ dir: '.audit' }), { await: true })\n",[432,879,880],{"__ignoreMap":467},[471,881,882,884,886,889,891,893,896,898,900,903,905,907,909,911,913,916,918,922,924],{"class":473,"line":474},[471,883,438],{"class":526},[471,885,530],{"class":485},[471,887,888],{"class":526},"createFsDrain",[471,890,530],{"class":485},[471,892,824],{"class":481},[471,894,895],{"class":632}," dir",[471,897,591],{"class":481},[471,899,495],{"class":481},[471,901,902],{"class":498},".audit",[471,904,533],{"class":481},[471,906,489],{"class":481},[471,908,860],{"class":485},[471,910,541],{"class":481},[471,912,482],{"class":481},[471,914,915],{"class":632}," await",[471,917,591],{"class":481},[471,919,921],{"class":920},"sfNiH"," true",[471,923,489],{"class":481},[471,925,926],{"class":485},")\n",[428,928,929,930,932],{},"The ",[432,931,873],{}," flag costs you a small bit of latency per request that records an audit (one synchronous drain call), but guarantees the audit hits disk before the response is sent. For compliance-grade audits, the trade-off is always worth it.",[445,934,935],{"id":442},[432,936,937],{},"signed()",[428,939,940,943],{},[432,941,942],{},"signed(drain, opts)"," adds tamper-evident integrity. Two strategies:",[945,946,947,963],"table",{},[948,949,950],"thead",{},[951,952,953,957,960],"tr",{},[954,955,956],"th",{},"Strategy",[954,958,959],{},"What it adds",[954,961,962],{},"Use case",[964,965,966,983],"tbody",{},[951,967,968,974,980],{},[969,970,971],"td",{},[432,972,973],{},"'hmac'",[969,975,976,979],{},[432,977,978],{},"event.audit.signature"," (HMAC of the canonical event)",[969,981,982],{},"Single-event integrity check (any later mutation fails verification).",[951,984,985,990,998],{},[969,986,987],{},[432,988,989],{},"'hash-chain'",[969,991,992,686,995],{},[432,993,994],{},"event.audit.prevHash",[432,996,997],{},"event.audit.hash",[969,999,1000],{},"A verifiable chain — deletions and reordering also become detectable.",[698,1002,1003,1009,1010,1014,1015,1017],{},[701,1004,1005,1006,1008],{},"What ",[432,1007,937],{}," actually buys you."," Detection, not prevention. Anyone with write access to the underlying sink can still nuke the file or table — but the chain proves ",[1011,1012,1013],"em",{},"which"," events were dropped or modified after the fact. Skip ",[432,1016,937],{}," if you already write to an append-only \u002F WORM store (S3 Object Lock, Postgres with row-level immutability, BigQuery append-only tables); doubling integrity layers just adds latency without raising the bar.",[1019,1020,1022],"h3",{"id":1021},"hmac","HMAC",[428,1024,1025],{},"Each event gets a signature. Tampering with one row breaks that row's verification, but doesn't break later rows.",[461,1027,1029],{"className":463,"code":1028,"language":466,"meta":467,"style":467},"import { signed } from 'evlog'\n\nsigned(drain, { strategy: 'hmac', secret: process.env.AUDIT_SECRET! })\n",[432,1030,1031,1050,1054],{"__ignoreMap":467},[471,1032,1033,1035,1037,1040,1042,1044,1046,1048],{"class":473,"line":474},[471,1034,478],{"class":477},[471,1036,482],{"class":481},[471,1038,1039],{"class":485}," signed",[471,1041,489],{"class":481},[471,1043,492],{"class":477},[471,1045,495],{"class":481},[471,1047,499],{"class":498},[471,1049,502],{"class":481},[471,1051,1052],{"class":473,"line":505},[471,1053,509],{"emptyLinePlaceholder":508},[471,1055,1056,1058,1061,1063,1065,1068,1070,1072,1074,1076,1078,1081,1083,1085,1087,1089,1091,1094,1097,1099],{"class":473,"line":512},[471,1057,442],{"class":526},[471,1059,1060],{"class":485},"(drain",[471,1062,541],{"class":481},[471,1064,482],{"class":481},[471,1066,1067],{"class":632}," strategy",[471,1069,591],{"class":481},[471,1071,495],{"class":481},[471,1073,1021],{"class":498},[471,1075,533],{"class":481},[471,1077,541],{"class":481},[471,1079,1080],{"class":632}," secret",[471,1082,591],{"class":481},[471,1084,845],{"class":485},[471,1086,518],{"class":481},[471,1088,850],{"class":485},[471,1090,518],{"class":481},[471,1092,1093],{"class":485},"AUDIT_SECRET",[471,1095,1096],{"class":481},"!",[471,1098,489],{"class":481},[471,1100,926],{"class":485},[1019,1102,1104],{"id":1103},"hash-chain","Hash-chain",[428,1106,1107],{},"Each event references the previous event's hash. Deleting any row breaks the chain forward of that point, so the verifier can pinpoint the exact row that was tampered with.",[461,1109,1111],{"className":463,"code":1110,"language":466,"meta":467,"style":467},"signed(drain, {\n  strategy: 'hash-chain',\n  state: {\n    load: () => fs.readFile('.audit\u002Fhead', 'utf8').catch(() => null),\n    save: (h) => fs.writeFile('.audit\u002Fhead', h),\n  },\n})\n",[432,1112,1113,1124,1139,1148,1207,1246,1251],{"__ignoreMap":467},[471,1114,1115,1117,1119,1121],{"class":473,"line":474},[471,1116,442],{"class":526},[471,1118,1060],{"class":485},[471,1120,541],{"class":481},[471,1122,1123],{"class":481}," {\n",[471,1125,1126,1129,1131,1133,1135,1137],{"class":473,"line":505},[471,1127,1128],{"class":632},"  strategy",[471,1130,591],{"class":481},[471,1132,495],{"class":481},[471,1134,1103],{"class":498},[471,1136,533],{"class":481},[471,1138,627],{"class":481},[471,1140,1141,1144,1146],{"class":473,"line":512},[471,1142,1143],{"class":632},"  state",[471,1145,591],{"class":481},[471,1147,1123],{"class":481},[471,1149,1150,1153,1155,1158,1160,1163,1165,1168,1170,1172,1175,1177,1179,1181,1184,1186,1188,1190,1193,1195,1198,1200,1203,1205],{"class":473,"line":666},[471,1151,1152],{"class":526},"    load",[471,1154,591],{"class":481},[471,1156,1157],{"class":481}," ()",[471,1159,599],{"class":598},[471,1161,1162],{"class":485}," fs",[471,1164,518],{"class":481},[471,1166,1167],{"class":526},"readFile",[471,1169,530],{"class":485},[471,1171,533],{"class":481},[471,1173,1174],{"class":498},".audit\u002Fhead",[471,1176,533],{"class":481},[471,1178,541],{"class":481},[471,1180,495],{"class":481},[471,1182,1183],{"class":498},"utf8",[471,1185,533],{"class":481},[471,1187,860],{"class":485},[471,1189,518],{"class":481},[471,1191,1192],{"class":526},"catch",[471,1194,530],{"class":485},[471,1196,1197],{"class":481},"()",[471,1199,599],{"class":598},[471,1201,1202],{"class":481}," null",[471,1204,860],{"class":485},[471,1206,627],{"class":481},[471,1208,1209,1212,1214,1217,1220,1222,1224,1226,1228,1231,1233,1235,1237,1239,1241,1244],{"class":473,"line":787},[471,1210,1211],{"class":526},"    save",[471,1213,591],{"class":481},[471,1215,1216],{"class":481}," (",[471,1218,1219],{"class":594},"h",[471,1221,860],{"class":481},[471,1223,599],{"class":598},[471,1225,1162],{"class":485},[471,1227,518],{"class":481},[471,1229,1230],{"class":526},"writeFile",[471,1232,530],{"class":485},[471,1234,533],{"class":481},[471,1236,1174],{"class":498},[471,1238,533],{"class":481},[471,1240,541],{"class":481},[471,1242,1243],{"class":485}," h)",[471,1245,627],{"class":481},[471,1247,1248],{"class":473,"line":816},[471,1249,1250],{"class":481},"  },\n",[471,1252,1253,1255],{"class":473,"line":865},[471,1254,669],{"class":481},[471,1256,926],{"class":485},[428,1258,929,1259,1262],{},[432,1260,1261],{},"state"," config is required for cross-process or durable chains: load the previous head hash from your own store (Redis, Postgres, file) before each event, save the new head after.",[1264,1265],"hash-chain-tamper",{},[1267,1268,1269,1270,1273,1274,1277,1278,518],"note",{},"A CLI to walk and verify the chain (",[432,1271,1272],{},"evlog audit verify",") is on the roadmap. Until then, validate by recomputing the hashes of stored events and comparing each ",[432,1275,1276],{},"prevHash"," against the previous event's ",[432,1279,1280],{},"hash",[1282,1283,1284],"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 .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}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 .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 .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 .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}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 .sfNiH, html code.shiki .sfNiH{--shiki-light:#FF5370;--shiki-default:#FF9CAC;--shiki-dark:#FF9CAC}",{"title":467,"searchDepth":505,"depth":505,"links":1286},[1287,1288,1289],{"id":447,"depth":505,"text":450},{"id":693,"depth":505,"text":696},{"id":442,"depth":505,"text":937,"children":1290},[1291,1292],{"id":1021,"depth":512,"text":1022},{"id":1103,"depth":512,"text":1104},"auditEnricher to auto-fill request context, auditOnly to route audits to a dedicated sink, and signed for tamper-evident HMAC or hash-chain integrity.","md",[1296,1299],{"label":142,"icon":145,"to":143,"color":1297,"variant":1298},"neutral","subtle",{"label":152,"icon":129,"to":153,"color":1297,"variant":1298},{},{"title":147,"icon":150},{"title":423,"description":1293},"_3JRqd31dDWZXAN9m-j4Ikhyg3JwAr_LT4cmpgR6ppw",[1305,1307],{"title":142,"path":143,"stem":144,"description":1306,"icon":145,"children":-1},"log.audit, log.audit.deny, standalone audit(), withAudit auto-instrumentation, defineAuditAction and defineAuditCatalog registries, and auditDiff change patches.",{"title":152,"path":153,"stem":154,"description":1308,"icon":129,"children":-1},"Integrity, redact presets, GDPR vs append-only, retention windows, and the most common pitfalls when shipping audit logs to production.",1778330170804]