[{"data":1,"prerenderedAt":1237},["ShallowReactive",2],{"navigation_docs":3,"-build-on-top-in-process-stream":454,"-build-on-top-in-process-stream-surround":1232},[4,35,159,201,289,352,438],{"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,297,302,307,312,316,321,326,330,334,338,342,347],{"title":41,"path":295,"stem":296,"icon":54},"\u002Fbuild-on-top\u002Foverview","5.build-on-top\u002F0.overview",{"title":298,"path":299,"stem":300,"icon":301},"In-process stream","\u002Fbuild-on-top\u002Fin-process-stream","5.build-on-top\u002F1.in-process-stream","i-lucide-radio-tower",{"title":303,"path":304,"stem":305,"icon":306},"Fanout","\u002Fbuild-on-top\u002Ffanout-and-multi-drain","5.build-on-top\u002F10.fanout-and-multi-drain","i-lucide-share-2",{"title":308,"path":309,"stem":310,"icon":311},"Identity headers","\u002Fbuild-on-top\u002Fidentity-headers","5.build-on-top\u002F11.identity-headers","i-lucide-fingerprint",{"title":313,"path":314,"stem":315,"icon":288},"Custom framework","\u002Fbuild-on-top\u002Fcustom-framework","5.build-on-top\u002F12.custom-framework",{"title":317,"path":318,"stem":319,"icon":320},"Stream server","\u002Fbuild-on-top\u002Fstream-server","5.build-on-top\u002F2.stream-server","i-lucide-radio",{"title":322,"path":323,"stem":324,"icon":325},"FS reader","\u002Fbuild-on-top\u002Ffs-reader","5.build-on-top\u002F3.fs-reader","i-lucide-folder-search",{"title":156,"path":327,"stem":328,"icon":329},"\u002Fbuild-on-top\u002Fconsumer-recipes","5.build-on-top\u002F4.consumer-recipes","i-lucide-chef-hat",{"title":331,"path":332,"stem":333,"icon":288},"Plugins","\u002Fbuild-on-top\u002Fplugins","5.build-on-top\u002F5.plugins",{"title":335,"path":336,"stem":337,"icon":28},"Custom enrichers","\u002Fbuild-on-top\u002Fcustom-enrichers","5.build-on-top\u002F6.custom-enrichers",{"title":339,"path":340,"stem":341,"icon":178},"Tail sampling","\u002Fbuild-on-top\u002Ftail-sampling","5.build-on-top\u002F7.tail-sampling",{"title":343,"path":344,"stem":345,"icon":346},"Custom drains","\u002Fbuild-on-top\u002Fcustom-drains","5.build-on-top\u002F8.custom-drains","i-lucide-code-2",{"title":348,"path":349,"stem":350,"icon":351},"Drain pipeline","\u002Fbuild-on-top\u002Fdrain-pipeline","5.build-on-top\u002F9.drain-pipeline","i-lucide-workflow",{"title":353,"path":354,"stem":355,"children":356,"page":34},"Adapters","\u002Fadapters","6.adapters",[357,360,400,415],{"title":41,"path":358,"stem":359,"icon":44},"\u002Fadapters\u002Foverview","6.adapters\u002F01.overview",{"title":361,"path":362,"stem":363,"children":364,"page":34},"Cloud destinations","\u002Fadapters\u002Fcloud","6.adapters\u002F02.cloud",[365,370,375,380,385,390,395],{"title":366,"path":367,"stem":368,"icon":369},"Axiom","\u002Fadapters\u002Fcloud\u002Faxiom","6.adapters\u002F02.cloud\u002F01.axiom","i-custom-axiom",{"title":371,"path":372,"stem":373,"icon":374},"OTLP","\u002Fadapters\u002Fcloud\u002Fotlp","6.adapters\u002F02.cloud\u002F02.otlp","i-simple-icons-opentelemetry",{"title":376,"path":377,"stem":378,"icon":379},"PostHog","\u002Fadapters\u002Fcloud\u002Fposthog","6.adapters\u002F02.cloud\u002F03.posthog","i-simple-icons-posthog",{"title":381,"path":382,"stem":383,"icon":384},"Sentry","\u002Fadapters\u002Fcloud\u002Fsentry","6.adapters\u002F02.cloud\u002F04.sentry","i-simple-icons-sentry",{"title":386,"path":387,"stem":388,"icon":389},"Better Stack","\u002Fadapters\u002Fcloud\u002Fbetter-stack","6.adapters\u002F02.cloud\u002F05.better-stack","i-simple-icons-betterstack",{"title":391,"path":392,"stem":393,"icon":394},"Datadog","\u002Fadapters\u002Fcloud\u002Fdatadog","6.adapters\u002F02.cloud\u002F06.datadog","i-simple-icons-datadog",{"title":396,"path":397,"stem":398,"icon":399},"HyperDX","\u002Fadapters\u002Fcloud\u002Fhyperdx","6.adapters\u002F02.cloud\u002F07.hyperdx","i-custom-hyperdx",{"title":401,"path":402,"stem":403,"children":404,"page":34},"Self-hosted","\u002Fadapters\u002Fself-hosted","6.adapters\u002F03.self-hosted",[405,410],{"title":406,"path":407,"stem":408,"icon":409},"File System","\u002Fadapters\u002Fself-hosted\u002Ffs","6.adapters\u002F03.self-hosted\u002F01.fs","i-lucide-hard-drive",{"title":411,"path":412,"stem":413,"icon":414},"NuxtHub","\u002Fadapters\u002Fself-hosted\u002Fnuxthub","6.adapters\u002F03.self-hosted\u002F02.nuxthub","i-simple-icons-nuxt",{"title":416,"path":417,"stem":418,"children":419,"page":34},"Building blocks","\u002Fadapters\u002Fbuilding-blocks","6.adapters\u002F04.building-blocks",[420,424,429,433],{"title":421,"path":422,"stem":423,"icon":351},"Pipeline","\u002Fadapters\u002Fbuilding-blocks\u002Fpipeline","6.adapters\u002F04.building-blocks\u002F01.pipeline",{"title":425,"path":426,"stem":427,"icon":428},"HTTP","\u002Fadapters\u002Fbuilding-blocks\u002Fhttp","6.adapters\u002F04.building-blocks\u002F02.http","i-lucide-globe",{"title":430,"path":431,"stem":432,"icon":83},"Custom Adapters","\u002Fadapters\u002Fbuilding-blocks\u002Fcustom","6.adapters\u002F04.building-blocks\u002F03.custom",{"title":434,"path":435,"stem":436,"icon":437},"Toolkit","\u002Fadapters\u002Fbuilding-blocks\u002Ftoolkit","6.adapters\u002F04.building-blocks\u002F04.toolkit","i-lucide-blocks",{"title":439,"path":440,"stem":441,"children":442,"page":34},"Enrichers","\u002Fenrichers","7.enrichers",[443,446,450],{"title":41,"path":444,"stem":445,"icon":28},"\u002Fenrichers\u002Foverview","7.enrichers\u002F1.overview",{"title":447,"path":448,"stem":449,"icon":288},"Built-in","\u002Fenrichers\u002Fbuilt-in","7.enrichers\u002F2.built-in",{"title":451,"path":452,"stem":453,"icon":83},"Custom","\u002Fenrichers\u002Fcustom","7.enrichers\u002F3.custom",{"id":455,"title":298,"body":456,"description":1225,"extension":1226,"links":1227,"meta":1228,"navigation":1229,"path":299,"seo":1230,"stem":300,"__hash__":1231},"docs\u002F5.build-on-top\u002F1.in-process-stream.md",{"type":457,"value":458,"toc":1214},"minimark",[459,480,490,501,637,642,645,650,749,752,756,860,875,879,888,988,992,999,1003,1009,1081,1085,1092,1176,1186,1190,1210],[460,461,462,466,467,470,471,475,476,479],"callout",{"icon":13},[463,464,465],"strong",{},"Looking for the network bridge?"," This page covers the ",[463,468,469],{},"in-process"," primitive (",[472,473,474],"code",{},"createStreamDrain",") — for subscribers running in the same Node process. For browser tabs, CLIs, or external devtools that connect over HTTP, see ",[477,478,317],"a",{"href":318},".",[481,482,483,486,487,489],"p",{},[472,484,485],{},"createStreamDrain()"," exposes the events flowing through evlog as an ",[463,488,469],{}," pub\u002Fsub. It's the primitive any local consumer can subscribe to without re-implementing a drain.",[460,491,492,498],{"icon":117},[481,493,494,497],{},[463,495,496],{},"Scope:"," the stream lives inside a single Node \u002F Bun \u002F Deno process. It sees events emitted from that process only.",[481,499,500],{},"That means it works 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 for cross-instance fan-out.",[502,503,508],"pre",{"className":504,"code":505,"language":506,"meta":507,"style":507},"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","",[472,509,510,543,550,588,593,600],{"__ignoreMap":507},[511,512,515,519,523,527,530,533,536,540],"span",{"class":513,"line":514},"line",1,[511,516,518],{"class":517},"s7zQu","import",[511,520,522],{"class":521},"sMK4o"," {",[511,524,526],{"class":525},"sTEyZ"," createStreamDrain",[511,528,529],{"class":521}," }",[511,531,532],{"class":517}," from",[511,534,535],{"class":521}," '",[511,537,539],{"class":538},"sfazB","evlog\u002Fstream",[511,541,542],{"class":521},"'\n",[511,544,546],{"class":513,"line":545},2,[511,547,549],{"emptyLinePlaceholder":548},true,"\n",[511,551,553,557,560,563,566,569,572,576,579,583,585],{"class":513,"line":552},3,[511,554,556],{"class":555},"spNyl","const",[511,558,559],{"class":525}," stream ",[511,561,562],{"class":521},"=",[511,564,526],{"class":565},"s2Zo4",[511,567,568],{"class":525},"(",[511,570,571],{"class":521},"{",[511,573,575],{"class":574},"swJcz"," buffer",[511,577,578],{"class":521},":",[511,580,582],{"class":581},"sbssI"," 200",[511,584,529],{"class":521},[511,586,587],{"class":525},")\n",[511,589,591],{"class":513,"line":590},4,[511,592,549],{"emptyLinePlaceholder":548},[511,594,596],{"class":513,"line":595},5,[511,597,599],{"class":598},"sHwdD","\u002F\u002F Register as a normal evlog drain (Nitro hook or plugin runner):\n",[511,601,603,606,608,611,613,616,618,621,624,626,629,632,634],{"class":513,"line":602},6,[511,604,605],{"class":525},"nitroApp",[511,607,479],{"class":521},[511,609,610],{"class":525},"hooks",[511,612,479],{"class":521},[511,614,615],{"class":565},"hook",[511,617,568],{"class":525},[511,619,620],{"class":521},"'",[511,622,623],{"class":538},"evlog:drain",[511,625,620],{"class":521},[511,627,628],{"class":521},",",[511,630,631],{"class":525}," stream",[511,633,479],{"class":521},[511,635,636],{"class":525},"drain)\n",[638,639,641],"h2",{"id":640},"subscribing","Subscribing",[481,643,644],{},"Two consumption styles are supported.",[646,647,649],"h3",{"id":648},"sync-listener","Sync listener",[502,651,653],{"className":504,"code":652,"language":506,"meta":507,"style":507},"const unsubscribe = stream.subscribe((event) => {\n  if (event.level === 'error') notifyOps(event)\n})\n\n\u002F\u002F Later:\nunsubscribe()\n",[472,654,655,688,725,732,736,741],{"__ignoreMap":507},[511,656,657,659,662,664,666,668,671,673,675,679,682,685],{"class":513,"line":514},[511,658,556],{"class":555},[511,660,661],{"class":525}," unsubscribe ",[511,663,562],{"class":521},[511,665,631],{"class":525},[511,667,479],{"class":521},[511,669,670],{"class":565},"subscribe",[511,672,568],{"class":525},[511,674,568],{"class":521},[511,676,678],{"class":677},"sHdIc","event",[511,680,681],{"class":521},")",[511,683,684],{"class":555}," =>",[511,686,687],{"class":521}," {\n",[511,689,690,693,696,698,700,703,706,708,711,713,716,719,721,723],{"class":513,"line":545},[511,691,692],{"class":517},"  if",[511,694,695],{"class":574}," (",[511,697,678],{"class":525},[511,699,479],{"class":521},[511,701,702],{"class":525},"level",[511,704,705],{"class":521}," ===",[511,707,535],{"class":521},[511,709,710],{"class":538},"error",[511,712,620],{"class":521},[511,714,715],{"class":574},") ",[511,717,718],{"class":565},"notifyOps",[511,720,568],{"class":574},[511,722,678],{"class":525},[511,724,587],{"class":574},[511,726,727,730],{"class":513,"line":552},[511,728,729],{"class":521},"}",[511,731,587],{"class":525},[511,733,734],{"class":513,"line":590},[511,735,549],{"emptyLinePlaceholder":548},[511,737,738],{"class":513,"line":595},[511,739,740],{"class":598},"\u002F\u002F Later:\n",[511,742,743,746],{"class":513,"line":602},[511,744,745],{"class":565},"unsubscribe",[511,747,748],{"class":525},"()\n",[481,750,751],{},"Listener errors are caught and logged — they never affect other subscribers or the drain.",[646,753,755],{"id":754},"async-iterator","Async iterator",[502,757,759],{"className":504,"code":758,"language":506,"meta":507,"style":507},"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",[472,760,761,792,833,855],{"__ignoreMap":507},[511,762,763,766,769,771,773,776,779,781,783,786,789],{"class":513,"line":514},[511,764,765],{"class":517},"for",[511,767,768],{"class":517}," await",[511,770,695],{"class":525},[511,772,556],{"class":555},[511,774,775],{"class":525}," event ",[511,777,778],{"class":521},"of",[511,780,631],{"class":525},[511,782,479],{"class":521},[511,784,785],{"class":565},"events",[511,787,788],{"class":525},"()) ",[511,790,791],{"class":521},"{\n",[511,793,794,797,799,802,804,806,808,811,813,816,818,821,824,826,828,831],{"class":513,"line":545},[511,795,796],{"class":525},"  console",[511,798,479],{"class":521},[511,800,801],{"class":565},"log",[511,803,568],{"class":574},[511,805,678],{"class":525},[511,807,479],{"class":521},[511,809,810],{"class":525},"timestamp",[511,812,628],{"class":521},[511,814,815],{"class":525}," event",[511,817,479],{"class":521},[511,819,820],{"class":525},"action",[511,822,823],{"class":521}," ??",[511,825,815],{"class":525},[511,827,479],{"class":521},[511,829,830],{"class":525},"message",[511,832,587],{"class":574},[511,834,835,837,839,842,844,846,849,852],{"class":513,"line":552},[511,836,692],{"class":517},[511,838,695],{"class":574},[511,840,841],{"class":565},"shouldStop",[511,843,568],{"class":574},[511,845,678],{"class":525},[511,847,848],{"class":574},")) ",[511,850,851],{"class":517},"break",[511,853,854],{"class":598},"  \u002F\u002F breaking cleanly unsubscribes\n",[511,856,857],{"class":513,"line":590},[511,858,859],{"class":521},"}\n",[481,861,862,863,866,867,870,871,874],{},"Each call to ",[472,864,865],{},"events()"," returns a fresh independent iterator. Past buffered events are ",[463,868,869],{},"not"," replayed; pair with ",[472,872,873],{},"stream.recent()"," to seed history.",[638,876,878],{"id":877},"replay-buffer","Replay buffer",[481,880,881,883,884,887],{},[472,882,873],{}," returns a defensive copy of the most recent events (oldest first). The default buffer holds 500 events; pass ",[472,885,886],{},"buffer: 0"," to disable, or set it explicitly:",[502,889,891],{"className":504,"code":890,"language":506,"meta":507,"style":507},"const stream = createStreamDrain({ buffer: 1000 })\n\nconst initial = stream.recent()\nfor (const past of initial) seedDashboard(past)\n\nstream.subscribe(liveEvent => updateDashboard(liveEvent))\n",[472,892,893,918,922,940,962,966],{"__ignoreMap":507},[511,894,895,897,899,901,903,905,907,909,911,914,916],{"class":513,"line":514},[511,896,556],{"class":555},[511,898,559],{"class":525},[511,900,562],{"class":521},[511,902,526],{"class":565},[511,904,568],{"class":525},[511,906,571],{"class":521},[511,908,575],{"class":574},[511,910,578],{"class":521},[511,912,913],{"class":581}," 1000",[511,915,529],{"class":521},[511,917,587],{"class":525},[511,919,920],{"class":513,"line":545},[511,921,549],{"emptyLinePlaceholder":548},[511,923,924,926,929,931,933,935,938],{"class":513,"line":552},[511,925,556],{"class":555},[511,927,928],{"class":525}," initial ",[511,930,562],{"class":521},[511,932,631],{"class":525},[511,934,479],{"class":521},[511,936,937],{"class":565},"recent",[511,939,748],{"class":525},[511,941,942,944,946,948,951,953,956,959],{"class":513,"line":590},[511,943,765],{"class":517},[511,945,695],{"class":525},[511,947,556],{"class":555},[511,949,950],{"class":525}," past ",[511,952,778],{"class":521},[511,954,955],{"class":525}," initial) ",[511,957,958],{"class":565},"seedDashboard",[511,960,961],{"class":525},"(past)\n",[511,963,964],{"class":513,"line":595},[511,965,549],{"emptyLinePlaceholder":548},[511,967,968,971,973,975,977,980,982,985],{"class":513,"line":602},[511,969,970],{"class":525},"stream",[511,972,479],{"class":521},[511,974,670],{"class":565},[511,976,568],{"class":525},[511,978,979],{"class":677},"liveEvent",[511,981,684],{"class":555},[511,983,984],{"class":565}," updateDashboard",[511,986,987],{"class":525},"(liveEvent))\n",[638,989,991],{"id":990},"backpressure","Backpressure",[481,993,994,995,998],{},"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 ",[472,996,997],{},"stream.droppedCount"," increments.",[638,1000,1002],{"id":1001},"filter","Filter",[481,1004,1005,1006,1008],{},"Events that fail the optional ",[472,1007,1001],{}," predicate are not buffered nor delivered:",[502,1010,1012],{"className":504,"code":1011,"language":506,"meta":507,"style":507},"const errors = createStreamDrain({\n  filter: event => event.level === 'error' || event.status >= 500,\n})\n",[472,1013,1014,1029,1075],{"__ignoreMap":507},[511,1015,1016,1018,1021,1023,1025,1027],{"class":513,"line":514},[511,1017,556],{"class":555},[511,1019,1020],{"class":525}," errors ",[511,1022,562],{"class":521},[511,1024,526],{"class":565},[511,1026,568],{"class":525},[511,1028,791],{"class":521},[511,1030,1031,1034,1036,1038,1040,1042,1044,1047,1050,1052,1054,1056,1059,1061,1063,1066,1069,1072],{"class":513,"line":545},[511,1032,1033],{"class":565},"  filter",[511,1035,578],{"class":521},[511,1037,815],{"class":677},[511,1039,684],{"class":555},[511,1041,815],{"class":525},[511,1043,479],{"class":521},[511,1045,1046],{"class":525},"level ",[511,1048,1049],{"class":521},"===",[511,1051,535],{"class":521},[511,1053,710],{"class":538},[511,1055,620],{"class":521},[511,1057,1058],{"class":521}," ||",[511,1060,815],{"class":525},[511,1062,479],{"class":521},[511,1064,1065],{"class":525},"status ",[511,1067,1068],{"class":521},">=",[511,1070,1071],{"class":581}," 500",[511,1073,1074],{"class":521},",\n",[511,1076,1077,1079],{"class":513,"line":552},[511,1078,729],{"class":521},[511,1080,587],{"class":525},[638,1082,1084],{"id":1083},"default-singleton","Default singleton",[481,1086,1087,1088,1091],{},"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 the ",[477,1089,1090],{"href":318},"stream server"," on the other — use the singleton accessors:",[502,1093,1095],{"className":504,"code":1094,"language":506,"meta":507,"style":507},"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",[472,1096,1097,1121,1125,1130,1154,1158,1163],{"__ignoreMap":507},[511,1098,1099,1101,1103,1106,1108,1111,1113,1115,1117,1119],{"class":513,"line":514},[511,1100,518],{"class":517},[511,1102,522],{"class":521},[511,1104,1105],{"class":525}," getDefaultStream",[511,1107,628],{"class":521},[511,1109,1110],{"class":525}," setDefaultStream",[511,1112,529],{"class":521},[511,1114,532],{"class":517},[511,1116,535],{"class":521},[511,1118,539],{"class":538},[511,1120,542],{"class":521},[511,1122,1123],{"class":513,"line":545},[511,1124,549],{"emptyLinePlaceholder":548},[511,1126,1127],{"class":513,"line":552},[511,1128,1129],{"class":598},"\u002F\u002F Lazily creates a singleton on first call\n",[511,1131,1132,1134,1136,1138,1140,1142,1144,1146,1148,1150,1152],{"class":513,"line":590},[511,1133,556],{"class":555},[511,1135,559],{"class":525},[511,1137,562],{"class":521},[511,1139,1105],{"class":565},[511,1141,568],{"class":525},[511,1143,571],{"class":521},[511,1145,575],{"class":574},[511,1147,578],{"class":521},[511,1149,1071],{"class":581},[511,1151,529],{"class":521},[511,1153,587],{"class":525},[511,1155,1156],{"class":513,"line":595},[511,1157,549],{"emptyLinePlaceholder":548},[511,1159,1160],{"class":513,"line":602},[511,1161,1162],{"class":598},"\u002F\u002F Reset (mostly useful in tests)\n",[511,1164,1166,1169,1171,1174],{"class":513,"line":1165},7,[511,1167,1168],{"class":565},"setDefaultStream",[511,1170,568],{"class":525},[511,1172,1173],{"class":521},"null",[511,1175,587],{"class":525},[481,1177,1178,1179,1181,1182,1185],{},"The mini ",[477,1180,1090],{"href":318}," uses this singleton internally, so anything draining into ",[472,1183,1184],{},"getDefaultStream()"," automatically reaches all SSE clients.",[638,1187,1189],{"id":1188},"going-further","Going further",[1191,1192,1193,1202],"ul",{},[1194,1195,1196,1199,1200,479],"li",{},[463,1197,1198],{},"Network bridge"," — expose this stream over HTTP for browser tabs \u002F CLIs \u002F external devtools. See the ",[477,1201,317],{"href":318},[1194,1203,1204,1206,1207,479],{},[463,1205,156],{}," — concrete consumer patterns (devtool, replay-then-live, aggregation). See ",[477,1208,1209],{"href":327},"Consumer recipes",[1211,1212,1213],"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":507,"searchDepth":545,"depth":545,"links":1215},[1216,1220,1221,1222,1223,1224],{"id":640,"depth":545,"text":641,"children":1217},[1218,1219],{"id":648,"depth":552,"text":649},{"id":754,"depth":552,"text":755},{"id":877,"depth":545,"text":878},{"id":990,"depth":545,"text":991},{"id":1001,"depth":545,"text":1002},{"id":1083,"depth":545,"text":1084},{"id":1188,"depth":545,"text":1189},"Subscribe to wide events flowing through evlog, in-process, with createStreamDrain — sync listeners, async iterators, and a ring buffer.","md",null,{},{"title":298,"icon":301},{"title":298,"description":1225},"8laSFa_tIFaDpUfB_hW116g830nquioKTmZb0QVBHx8",[1233,1235],{"title":41,"path":295,"stem":296,"description":1234,"icon":54,"children":-1},"Live event observation, custom drains, plugins, custom enrichers, identity headers, framework integration — everything you can wire on top of the evlog pipeline.",{"title":303,"path":304,"stem":305,"description":1236,"icon":306,"children":-1},"Send the same wide event to several destinations in parallel — Axiom plus Datadog plus Sentry plus the local fs drain — through a single pipeline.",1778340168613]