[{"data":1,"prerenderedAt":1181},["ShallowReactive",2],{"navigation_docs":3,"-build-on-top-stream-api":421,"-build-on-top-stream-api-surround":1176},[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":300,"body":423,"description":1169,"extension":1170,"links":1171,"meta":1172,"navigation":1173,"path":301,"seo":1174,"stem":302,"__hash__":1175},"docs\u002F5.build-on-top\u002F2.stream-api.md",{"type":424,"value":425,"toc":1158},"minimark",[426,439,460,597,602,605,610,709,712,716,820,834,838,847,947,951,958,962,968,1040,1044,1047,1131,1135,1154],[427,428,429,433,434,438],"p",{},[430,431,432],"code",{},"createStreamDrain()"," exposes the events flowing through evlog as an ",[435,436,437],"strong",{},"in-process"," pub\u002Fsub. It's the primitive any local consumer can subscribe to — dashboards, devtools, CLIs, custom UIs — without re-implementing a drain.",[440,441,442,457],"callout",{"icon":13},[427,443,444,447,448,452,453,456],{},[435,445,446],{},"Scope:"," the stream lives inside a single Node \u002F Bun \u002F Deno process. It sees events emitted from that process only — like the ",[449,450,451],"a",{"href":373},"filesystem drain",". It is ",[435,454,455],{},"not"," a cross-process bus.",[427,458,459],{},"That means it works perfectly during local development, on long-lived self-hosted servers, and inside containers. On serverless platforms (Vercel Functions, Cloudflare Workers, AWS Lambda…), each invocation is a separate isolate, so a subscriber in one invocation will not see events emitted from another. Use a real broker (Redis Streams, NATS, Pub\u002FSub…) when you need cross-instance fan-out.",[461,462,467],"pre",{"className":463,"code":464,"language":465,"meta":466,"style":466},"language-ts shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","import { createStreamDrain } from 'evlog\u002Fstream'\n\nconst stream = createStreamDrain({ buffer: 200 })\n\n\u002F\u002F Register as a normal evlog drain (Nitro hook or plugin runner):\nnitroApp.hooks.hook('evlog:drain', stream.drain)\n","ts","",[430,468,469,502,509,547,552,559],{"__ignoreMap":466},[470,471,474,478,482,486,489,492,495,499],"span",{"class":472,"line":473},"line",1,[470,475,477],{"class":476},"s7zQu","import",[470,479,481],{"class":480},"sMK4o"," {",[470,483,485],{"class":484},"sTEyZ"," createStreamDrain",[470,487,488],{"class":480}," }",[470,490,491],{"class":476}," from",[470,493,494],{"class":480}," '",[470,496,498],{"class":497},"sfazB","evlog\u002Fstream",[470,500,501],{"class":480},"'\n",[470,503,505],{"class":472,"line":504},2,[470,506,508],{"emptyLinePlaceholder":507},true,"\n",[470,510,512,516,519,522,525,528,531,535,538,542,544],{"class":472,"line":511},3,[470,513,515],{"class":514},"spNyl","const",[470,517,518],{"class":484}," stream ",[470,520,521],{"class":480},"=",[470,523,485],{"class":524},"s2Zo4",[470,526,527],{"class":484},"(",[470,529,530],{"class":480},"{",[470,532,534],{"class":533},"swJcz"," buffer",[470,536,537],{"class":480},":",[470,539,541],{"class":540},"sbssI"," 200",[470,543,488],{"class":480},[470,545,546],{"class":484},")\n",[470,548,550],{"class":472,"line":549},4,[470,551,508],{"emptyLinePlaceholder":507},[470,553,555],{"class":472,"line":554},5,[470,556,558],{"class":557},"sHwdD","\u002F\u002F Register as a normal evlog drain (Nitro hook or plugin runner):\n",[470,560,562,565,568,571,573,576,578,581,584,586,589,592,594],{"class":472,"line":561},6,[470,563,564],{"class":484},"nitroApp",[470,566,567],{"class":480},".",[470,569,570],{"class":484},"hooks",[470,572,567],{"class":480},[470,574,575],{"class":524},"hook",[470,577,527],{"class":484},[470,579,580],{"class":480},"'",[470,582,583],{"class":497},"evlog:drain",[470,585,580],{"class":480},[470,587,588],{"class":480},",",[470,590,591],{"class":484}," stream",[470,593,567],{"class":480},[470,595,596],{"class":484},"drain)\n",[598,599,601],"h2",{"id":600},"subscribing","Subscribing",[427,603,604],{},"Two consumption styles are supported.",[606,607,609],"h3",{"id":608},"sync-listener","Sync listener",[461,611,613],{"className":463,"code":612,"language":465,"meta":466,"style":466},"const unsubscribe = stream.subscribe((event) => {\n  if (event.level === 'error') notifyOps(event)\n})\n\n\u002F\u002F Later:\nunsubscribe()\n",[430,614,615,648,685,692,696,701],{"__ignoreMap":466},[470,616,617,619,622,624,626,628,631,633,635,639,642,645],{"class":472,"line":473},[470,618,515],{"class":514},[470,620,621],{"class":484}," unsubscribe ",[470,623,521],{"class":480},[470,625,591],{"class":484},[470,627,567],{"class":480},[470,629,630],{"class":524},"subscribe",[470,632,527],{"class":484},[470,634,527],{"class":480},[470,636,638],{"class":637},"sHdIc","event",[470,640,641],{"class":480},")",[470,643,644],{"class":514}," =>",[470,646,647],{"class":480}," {\n",[470,649,650,653,656,658,660,663,666,668,671,673,676,679,681,683],{"class":472,"line":504},[470,651,652],{"class":476},"  if",[470,654,655],{"class":533}," (",[470,657,638],{"class":484},[470,659,567],{"class":480},[470,661,662],{"class":484},"level",[470,664,665],{"class":480}," ===",[470,667,494],{"class":480},[470,669,670],{"class":497},"error",[470,672,580],{"class":480},[470,674,675],{"class":533},") ",[470,677,678],{"class":524},"notifyOps",[470,680,527],{"class":533},[470,682,638],{"class":484},[470,684,546],{"class":533},[470,686,687,690],{"class":472,"line":511},[470,688,689],{"class":480},"}",[470,691,546],{"class":484},[470,693,694],{"class":472,"line":549},[470,695,508],{"emptyLinePlaceholder":507},[470,697,698],{"class":472,"line":554},[470,699,700],{"class":557},"\u002F\u002F Later:\n",[470,702,703,706],{"class":472,"line":561},[470,704,705],{"class":524},"unsubscribe",[470,707,708],{"class":484},"()\n",[427,710,711],{},"Listener errors are caught and logged — they never affect other subscribers or the drain.",[606,713,715],{"id":714},"async-iterator","Async iterator",[461,717,719],{"className":463,"code":718,"language":465,"meta":466,"style":466},"for await (const event of stream.events()) {\n  console.log(event.timestamp, event.action ?? event.message)\n  if (shouldStop(event)) break  \u002F\u002F breaking cleanly unsubscribes\n}\n",[430,720,721,752,793,815],{"__ignoreMap":466},[470,722,723,726,729,731,733,736,739,741,743,746,749],{"class":472,"line":473},[470,724,725],{"class":476},"for",[470,727,728],{"class":476}," await",[470,730,655],{"class":484},[470,732,515],{"class":514},[470,734,735],{"class":484}," event ",[470,737,738],{"class":480},"of",[470,740,591],{"class":484},[470,742,567],{"class":480},[470,744,745],{"class":524},"events",[470,747,748],{"class":484},"()) ",[470,750,751],{"class":480},"{\n",[470,753,754,757,759,762,764,766,768,771,773,776,778,781,784,786,788,791],{"class":472,"line":504},[470,755,756],{"class":484},"  console",[470,758,567],{"class":480},[470,760,761],{"class":524},"log",[470,763,527],{"class":533},[470,765,638],{"class":484},[470,767,567],{"class":480},[470,769,770],{"class":484},"timestamp",[470,772,588],{"class":480},[470,774,775],{"class":484}," event",[470,777,567],{"class":480},[470,779,780],{"class":484},"action",[470,782,783],{"class":480}," ??",[470,785,775],{"class":484},[470,787,567],{"class":480},[470,789,790],{"class":484},"message",[470,792,546],{"class":533},[470,794,795,797,799,802,804,806,809,812],{"class":472,"line":511},[470,796,652],{"class":476},[470,798,655],{"class":533},[470,800,801],{"class":524},"shouldStop",[470,803,527],{"class":533},[470,805,638],{"class":484},[470,807,808],{"class":533},")) ",[470,810,811],{"class":476},"break",[470,813,814],{"class":557},"  \u002F\u002F breaking cleanly unsubscribes\n",[470,816,817],{"class":472,"line":549},[470,818,819],{"class":480},"}\n",[427,821,822,823,826,827,829,830,833],{},"Each call to ",[430,824,825],{},"events()"," returns a fresh independent iterator. Past buffered events are ",[435,828,455],{}," replayed; pair with ",[430,831,832],{},"stream.recent()"," to seed history.",[598,835,837],{"id":836},"replay-buffer","Replay buffer",[427,839,840,842,843,846],{},[430,841,832],{}," returns a defensive copy of the most recent events (oldest first). The default buffer holds 500 events; pass ",[430,844,845],{},"buffer: 0"," to disable, or set it explicitly:",[461,848,850],{"className":463,"code":849,"language":465,"meta":466,"style":466},"const stream = createStreamDrain({ buffer: 1000 })\n\nconst initial = stream.recent()\nfor (const past of initial) seedDashboard(past)\n\nstream.subscribe(liveEvent => updateDashboard(liveEvent))\n",[430,851,852,877,881,899,921,925],{"__ignoreMap":466},[470,853,854,856,858,860,862,864,866,868,870,873,875],{"class":472,"line":473},[470,855,515],{"class":514},[470,857,518],{"class":484},[470,859,521],{"class":480},[470,861,485],{"class":524},[470,863,527],{"class":484},[470,865,530],{"class":480},[470,867,534],{"class":533},[470,869,537],{"class":480},[470,871,872],{"class":540}," 1000",[470,874,488],{"class":480},[470,876,546],{"class":484},[470,878,879],{"class":472,"line":504},[470,880,508],{"emptyLinePlaceholder":507},[470,882,883,885,888,890,892,894,897],{"class":472,"line":511},[470,884,515],{"class":514},[470,886,887],{"class":484}," initial ",[470,889,521],{"class":480},[470,891,591],{"class":484},[470,893,567],{"class":480},[470,895,896],{"class":524},"recent",[470,898,708],{"class":484},[470,900,901,903,905,907,910,912,915,918],{"class":472,"line":549},[470,902,725],{"class":476},[470,904,655],{"class":484},[470,906,515],{"class":514},[470,908,909],{"class":484}," past ",[470,911,738],{"class":480},[470,913,914],{"class":484}," initial) ",[470,916,917],{"class":524},"seedDashboard",[470,919,920],{"class":484},"(past)\n",[470,922,923],{"class":472,"line":554},[470,924,508],{"emptyLinePlaceholder":507},[470,926,927,930,932,934,936,939,941,944],{"class":472,"line":561},[470,928,929],{"class":484},"stream",[470,931,567],{"class":480},[470,933,630],{"class":524},[470,935,527],{"class":484},[470,937,938],{"class":637},"liveEvent",[470,940,644],{"class":514},[470,942,943],{"class":524}," updateDashboard",[470,945,946],{"class":484},"(liveEvent))\n",[598,948,950],{"id":949},"backpressure","Backpressure",[427,952,953,954,957],{},"A slow async-iterator consumer never blocks the drain. Each iterator has a per-subscriber queue (default 1000); when it overflows, the oldest queued events are dropped and ",[430,955,956],{},"stream.droppedCount"," increments.",[598,959,961],{"id":960},"filter","Filter",[427,963,964,965,967],{},"Events that fail the optional ",[430,966,960],{}," predicate are not buffered nor delivered:",[461,969,971],{"className":463,"code":970,"language":465,"meta":466,"style":466},"const errors = createStreamDrain({\n  filter: event => event.level === 'error' || event.status >= 500,\n})\n",[430,972,973,988,1034],{"__ignoreMap":466},[470,974,975,977,980,982,984,986],{"class":472,"line":473},[470,976,515],{"class":514},[470,978,979],{"class":484}," errors ",[470,981,521],{"class":480},[470,983,485],{"class":524},[470,985,527],{"class":484},[470,987,751],{"class":480},[470,989,990,993,995,997,999,1001,1003,1006,1009,1011,1013,1015,1018,1020,1022,1025,1028,1031],{"class":472,"line":504},[470,991,992],{"class":524},"  filter",[470,994,537],{"class":480},[470,996,775],{"class":637},[470,998,644],{"class":514},[470,1000,775],{"class":484},[470,1002,567],{"class":480},[470,1004,1005],{"class":484},"level ",[470,1007,1008],{"class":480},"===",[470,1010,494],{"class":480},[470,1012,670],{"class":497},[470,1014,580],{"class":480},[470,1016,1017],{"class":480}," ||",[470,1019,775],{"class":484},[470,1021,567],{"class":480},[470,1023,1024],{"class":484},"status ",[470,1026,1027],{"class":480},">=",[470,1029,1030],{"class":540}," 500",[470,1032,1033],{"class":480},",\n",[470,1035,1036,1038],{"class":472,"line":511},[470,1037,689],{"class":480},[470,1039,546],{"class":484},[598,1041,1043],{"id":1042},"default-singleton","Default singleton",[427,1045,1046],{},"When several pieces of code in the same process need to share a single stream — typically a framework integration that wires the drain on one side and a consumer (UI, route, plugin) on the other — use the singleton accessors instead of passing references around:",[461,1048,1050],{"className":463,"code":1049,"language":465,"meta":466,"style":466},"import { getDefaultStream, setDefaultStream } from 'evlog\u002Fstream'\n\n\u002F\u002F Lazily creates a singleton on first call\nconst stream = getDefaultStream({ buffer: 500 })\n\n\u002F\u002F Reset (mostly useful in tests)\nsetDefaultStream(null)\n",[430,1051,1052,1076,1080,1085,1109,1113,1118],{"__ignoreMap":466},[470,1053,1054,1056,1058,1061,1063,1066,1068,1070,1072,1074],{"class":472,"line":473},[470,1055,477],{"class":476},[470,1057,481],{"class":480},[470,1059,1060],{"class":484}," getDefaultStream",[470,1062,588],{"class":480},[470,1064,1065],{"class":484}," setDefaultStream",[470,1067,488],{"class":480},[470,1069,491],{"class":476},[470,1071,494],{"class":480},[470,1073,498],{"class":497},[470,1075,501],{"class":480},[470,1077,1078],{"class":472,"line":504},[470,1079,508],{"emptyLinePlaceholder":507},[470,1081,1082],{"class":472,"line":511},[470,1083,1084],{"class":557},"\u002F\u002F Lazily creates a singleton on first call\n",[470,1086,1087,1089,1091,1093,1095,1097,1099,1101,1103,1105,1107],{"class":472,"line":549},[470,1088,515],{"class":514},[470,1090,518],{"class":484},[470,1092,521],{"class":480},[470,1094,1060],{"class":524},[470,1096,527],{"class":484},[470,1098,530],{"class":480},[470,1100,534],{"class":533},[470,1102,537],{"class":480},[470,1104,1030],{"class":540},[470,1106,488],{"class":480},[470,1108,546],{"class":484},[470,1110,1111],{"class":472,"line":554},[470,1112,508],{"emptyLinePlaceholder":507},[470,1114,1115],{"class":472,"line":561},[470,1116,1117],{"class":557},"\u002F\u002F Reset (mostly useful in tests)\n",[470,1119,1121,1124,1126,1129],{"class":472,"line":1120},7,[470,1122,1123],{"class":524},"setDefaultStream",[470,1125,527],{"class":484},[470,1127,1128],{"class":480},"null",[470,1130,546],{"class":484},[598,1132,1134],{"id":1133},"going-further","Going further",[1136,1137,1138,1147],"ul",{},[1139,1140,1141,1144,1145,567],"li",{},[435,1142,1143],{},"Network bridge"," — expose this stream over HTTP (Server-Sent Events) so a browser tab, a CLI, or any external consumer can subscribe. See the ",[449,1146,305],{"href":306},[1139,1148,1149,1151,1152,567],{},[435,1150,156],{}," — concrete patterns built on top of the stream + SSE bridge: minimal devtool, curl + jq inspection, replay-then-live, consumer-side filtering. See ",[449,1153,156],{"href":315},[1155,1156,1157],"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 .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}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 .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}",{"title":466,"searchDepth":504,"depth":504,"links":1159},[1160,1164,1165,1166,1167,1168],{"id":600,"depth":504,"text":601,"children":1161},[1162,1163],{"id":608,"depth":511,"text":609},{"id":714,"depth":511,"text":715},{"id":836,"depth":504,"text":837},{"id":949,"depth":504,"text":950},{"id":960,"depth":504,"text":961},{"id":1042,"depth":504,"text":1043},{"id":1133,"depth":504,"text":1134},"Subscribe to wide events flowing through evlog, in-process, with createStreamDrain — sync listeners, async iterators, and a ring buffer.","md",null,{},{"title":300,"icon":303},{"title":300,"description":1169},"VVP38W2Kz48cdKiJxbuRBMdCGPoijzgztZR8I4edTpc",[1177,1179],{"title":295,"path":296,"stem":297,"description":1178,"icon":298,"children":-1},"Every drain request sent by evlog is tagged with a User-Agent and an X-Evlog-Source header so receivers can identify the traffic.",{"title":305,"path":306,"stem":307,"description":1180,"icon":308,"children":-1},"Expose the in-process evlog stream over Server-Sent Events for local devtools, dashboards, and any browser tab. Local development and self-hosted only.",1778333327091]