[{"data":1,"prerenderedAt":1303},["ShallowReactive",2],{"navigation_docs":3,"-build-on-top-in-process-stream":454,"-build-on-top-in-process-stream-surround":1298},[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":1291,"extension":1292,"links":1293,"meta":1294,"navigation":1295,"path":299,"seo":1296,"stem":300,"__hash__":1297},"docs\u002F5.build-on-top\u002F1.in-process-stream.md",{"type":457,"value":458,"toc":1280},"minimark",[459,480,490,560,571,706,711,714,719,817,820,824,928,943,947,956,1056,1060,1067,1071,1077,1149,1153,1160,1244,1254,1258,1276],[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.",[491,492,495,498,552],"prompt",{":actions":493,"description":494,"icon":301},"[\"copy\",\"cursor\",\"windsurf\"]","Subscribe to wide events in-process",[481,496,497],{},"Wire an in-process subscriber on top of evlog's stream drain.",[499,500,501,512,527,538,549],"ul",{},[502,503,504,505,507,508,511],"li",{},"Import ",[472,506,474],{}," from ",[472,509,510],{},"evlog\u002Fstream"," and call it once at app boot",[502,513,514,515,518,519,522,523,526],{},"Register the returned ",[472,516,517],{},"drain"," on the evlog drain hook for my framework (Nitro: ",[472,520,521],{},"nitroApp.hooks.hook('evlog:drain', stream.drain)","; Next\u002Fstandalone: pass to ",[472,524,525],{},"initLogger({ drain })",")",[502,528,529,530,533,534,537],{},"Subscribe with ",[472,531,532],{},"stream.subscribe((event) => ...)"," for sync listeners or ",[472,535,536],{},"for await (const event of stream.events())"," for async iteration",[502,539,540,541,544,545,548],{},"Tune ",[472,542,543],{},"buffer"," for replay history and ",[472,546,547],{},"perSubscriberQueue"," for slow consumer backpressure",[502,550,551],{},"Skip on serverless platforms (Vercel Functions, Cloudflare Workers, AWS Lambda) — the stream is in-process, isolated invocations won't share it",[481,553,554,555],{},"Docs: ",[477,556,557],{"href":557,"rel":558},"https:\u002F\u002Fwww.evlog.dev\u002Fbuild-on-top\u002Fin-process-stream",[559],"nofollow",[460,561,562,568],{"icon":117},[481,563,564,567],{},[463,565,566],{},"Scope:"," the stream lives inside a single Node \u002F Bun \u002F Deno process. It sees events emitted from that process only.",[481,569,570],{},"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.",[572,573,578],"pre",{"className":574,"code":575,"language":576,"meta":577,"style":577},"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,579,580,612,619,657,662,669],{"__ignoreMap":577},[581,582,585,589,593,597,600,603,606,609],"span",{"class":583,"line":584},"line",1,[581,586,588],{"class":587},"s7zQu","import",[581,590,592],{"class":591},"sMK4o"," {",[581,594,596],{"class":595},"sTEyZ"," createStreamDrain",[581,598,599],{"class":591}," }",[581,601,602],{"class":587}," from",[581,604,605],{"class":591}," '",[581,607,510],{"class":608},"sfazB",[581,610,611],{"class":591},"'\n",[581,613,615],{"class":583,"line":614},2,[581,616,618],{"emptyLinePlaceholder":617},true,"\n",[581,620,622,626,629,632,635,638,641,645,648,652,654],{"class":583,"line":621},3,[581,623,625],{"class":624},"spNyl","const",[581,627,628],{"class":595}," stream ",[581,630,631],{"class":591},"=",[581,633,596],{"class":634},"s2Zo4",[581,636,637],{"class":595},"(",[581,639,640],{"class":591},"{",[581,642,644],{"class":643},"swJcz"," buffer",[581,646,647],{"class":591},":",[581,649,651],{"class":650},"sbssI"," 200",[581,653,599],{"class":591},[581,655,656],{"class":595},")\n",[581,658,660],{"class":583,"line":659},4,[581,661,618],{"emptyLinePlaceholder":617},[581,663,665],{"class":583,"line":664},5,[581,666,668],{"class":667},"sHwdD","\u002F\u002F Register as a normal evlog drain (Nitro hook or plugin runner):\n",[581,670,672,675,677,680,682,685,687,690,693,695,698,701,703],{"class":583,"line":671},6,[581,673,674],{"class":595},"nitroApp",[581,676,479],{"class":591},[581,678,679],{"class":595},"hooks",[581,681,479],{"class":591},[581,683,684],{"class":634},"hook",[581,686,637],{"class":595},[581,688,689],{"class":591},"'",[581,691,692],{"class":608},"evlog:drain",[581,694,689],{"class":591},[581,696,697],{"class":591},",",[581,699,700],{"class":595}," stream",[581,702,479],{"class":591},[581,704,705],{"class":595},"drain)\n",[707,708,710],"h2",{"id":709},"subscribing","Subscribing",[481,712,713],{},"Two consumption styles are supported.",[715,716,718],"h3",{"id":717},"sync-listener","Sync listener",[572,720,722],{"className":574,"code":721,"language":576,"meta":577,"style":577},"const unsubscribe = stream.subscribe((event) => {\n  if (event.level === 'error') notifyOps(event)\n})\n\n\u002F\u002F Later:\nunsubscribe()\n",[472,723,724,756,793,800,804,809],{"__ignoreMap":577},[581,725,726,728,731,733,735,737,740,742,744,748,750,753],{"class":583,"line":584},[581,727,625],{"class":624},[581,729,730],{"class":595}," unsubscribe ",[581,732,631],{"class":591},[581,734,700],{"class":595},[581,736,479],{"class":591},[581,738,739],{"class":634},"subscribe",[581,741,637],{"class":595},[581,743,637],{"class":591},[581,745,747],{"class":746},"sHdIc","event",[581,749,526],{"class":591},[581,751,752],{"class":624}," =>",[581,754,755],{"class":591}," {\n",[581,757,758,761,764,766,768,771,774,776,779,781,784,787,789,791],{"class":583,"line":614},[581,759,760],{"class":587},"  if",[581,762,763],{"class":643}," (",[581,765,747],{"class":595},[581,767,479],{"class":591},[581,769,770],{"class":595},"level",[581,772,773],{"class":591}," ===",[581,775,605],{"class":591},[581,777,778],{"class":608},"error",[581,780,689],{"class":591},[581,782,783],{"class":643},") ",[581,785,786],{"class":634},"notifyOps",[581,788,637],{"class":643},[581,790,747],{"class":595},[581,792,656],{"class":643},[581,794,795,798],{"class":583,"line":621},[581,796,797],{"class":591},"}",[581,799,656],{"class":595},[581,801,802],{"class":583,"line":659},[581,803,618],{"emptyLinePlaceholder":617},[581,805,806],{"class":583,"line":664},[581,807,808],{"class":667},"\u002F\u002F Later:\n",[581,810,811,814],{"class":583,"line":671},[581,812,813],{"class":634},"unsubscribe",[581,815,816],{"class":595},"()\n",[481,818,819],{},"Listener errors are caught and logged — they never affect other subscribers or the drain.",[715,821,823],{"id":822},"async-iterator","Async iterator",[572,825,827],{"className":574,"code":826,"language":576,"meta":577,"style":577},"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,828,829,860,901,923],{"__ignoreMap":577},[581,830,831,834,837,839,841,844,847,849,851,854,857],{"class":583,"line":584},[581,832,833],{"class":587},"for",[581,835,836],{"class":587}," await",[581,838,763],{"class":595},[581,840,625],{"class":624},[581,842,843],{"class":595}," event ",[581,845,846],{"class":591},"of",[581,848,700],{"class":595},[581,850,479],{"class":591},[581,852,853],{"class":634},"events",[581,855,856],{"class":595},"()) ",[581,858,859],{"class":591},"{\n",[581,861,862,865,867,870,872,874,876,879,881,884,886,889,892,894,896,899],{"class":583,"line":614},[581,863,864],{"class":595},"  console",[581,866,479],{"class":591},[581,868,869],{"class":634},"log",[581,871,637],{"class":643},[581,873,747],{"class":595},[581,875,479],{"class":591},[581,877,878],{"class":595},"timestamp",[581,880,697],{"class":591},[581,882,883],{"class":595}," event",[581,885,479],{"class":591},[581,887,888],{"class":595},"action",[581,890,891],{"class":591}," ??",[581,893,883],{"class":595},[581,895,479],{"class":591},[581,897,898],{"class":595},"message",[581,900,656],{"class":643},[581,902,903,905,907,910,912,914,917,920],{"class":583,"line":621},[581,904,760],{"class":587},[581,906,763],{"class":643},[581,908,909],{"class":634},"shouldStop",[581,911,637],{"class":643},[581,913,747],{"class":595},[581,915,916],{"class":643},")) ",[581,918,919],{"class":587},"break",[581,921,922],{"class":667},"  \u002F\u002F breaking cleanly unsubscribes\n",[581,924,925],{"class":583,"line":659},[581,926,927],{"class":591},"}\n",[481,929,930,931,934,935,938,939,942],{},"Each call to ",[472,932,933],{},"events()"," returns a fresh independent iterator. Past buffered events are ",[463,936,937],{},"not"," replayed; pair with ",[472,940,941],{},"stream.recent()"," to seed history.",[707,944,946],{"id":945},"replay-buffer","Replay buffer",[481,948,949,951,952,955],{},[472,950,941],{}," returns a defensive copy of the most recent events (oldest first). The default buffer holds 500 events; pass ",[472,953,954],{},"buffer: 0"," to disable, or set it explicitly:",[572,957,959],{"className":574,"code":958,"language":576,"meta":577,"style":577},"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,960,961,986,990,1008,1030,1034],{"__ignoreMap":577},[581,962,963,965,967,969,971,973,975,977,979,982,984],{"class":583,"line":584},[581,964,625],{"class":624},[581,966,628],{"class":595},[581,968,631],{"class":591},[581,970,596],{"class":634},[581,972,637],{"class":595},[581,974,640],{"class":591},[581,976,644],{"class":643},[581,978,647],{"class":591},[581,980,981],{"class":650}," 1000",[581,983,599],{"class":591},[581,985,656],{"class":595},[581,987,988],{"class":583,"line":614},[581,989,618],{"emptyLinePlaceholder":617},[581,991,992,994,997,999,1001,1003,1006],{"class":583,"line":621},[581,993,625],{"class":624},[581,995,996],{"class":595}," initial ",[581,998,631],{"class":591},[581,1000,700],{"class":595},[581,1002,479],{"class":591},[581,1004,1005],{"class":634},"recent",[581,1007,816],{"class":595},[581,1009,1010,1012,1014,1016,1019,1021,1024,1027],{"class":583,"line":659},[581,1011,833],{"class":587},[581,1013,763],{"class":595},[581,1015,625],{"class":624},[581,1017,1018],{"class":595}," past ",[581,1020,846],{"class":591},[581,1022,1023],{"class":595}," initial) ",[581,1025,1026],{"class":634},"seedDashboard",[581,1028,1029],{"class":595},"(past)\n",[581,1031,1032],{"class":583,"line":664},[581,1033,618],{"emptyLinePlaceholder":617},[581,1035,1036,1039,1041,1043,1045,1048,1050,1053],{"class":583,"line":671},[581,1037,1038],{"class":595},"stream",[581,1040,479],{"class":591},[581,1042,739],{"class":634},[581,1044,637],{"class":595},[581,1046,1047],{"class":746},"liveEvent",[581,1049,752],{"class":624},[581,1051,1052],{"class":634}," updateDashboard",[581,1054,1055],{"class":595},"(liveEvent))\n",[707,1057,1059],{"id":1058},"backpressure","Backpressure",[481,1061,1062,1063,1066],{},"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,1064,1065],{},"stream.droppedCount"," increments.",[707,1068,1070],{"id":1069},"filter","Filter",[481,1072,1073,1074,1076],{},"Events that fail the optional ",[472,1075,1069],{}," predicate are not buffered nor delivered:",[572,1078,1080],{"className":574,"code":1079,"language":576,"meta":577,"style":577},"const errors = createStreamDrain({\n  filter: event => event.level === 'error' || event.status >= 500,\n})\n",[472,1081,1082,1097,1143],{"__ignoreMap":577},[581,1083,1084,1086,1089,1091,1093,1095],{"class":583,"line":584},[581,1085,625],{"class":624},[581,1087,1088],{"class":595}," errors ",[581,1090,631],{"class":591},[581,1092,596],{"class":634},[581,1094,637],{"class":595},[581,1096,859],{"class":591},[581,1098,1099,1102,1104,1106,1108,1110,1112,1115,1118,1120,1122,1124,1127,1129,1131,1134,1137,1140],{"class":583,"line":614},[581,1100,1101],{"class":634},"  filter",[581,1103,647],{"class":591},[581,1105,883],{"class":746},[581,1107,752],{"class":624},[581,1109,883],{"class":595},[581,1111,479],{"class":591},[581,1113,1114],{"class":595},"level ",[581,1116,1117],{"class":591},"===",[581,1119,605],{"class":591},[581,1121,778],{"class":608},[581,1123,689],{"class":591},[581,1125,1126],{"class":591}," ||",[581,1128,883],{"class":595},[581,1130,479],{"class":591},[581,1132,1133],{"class":595},"status ",[581,1135,1136],{"class":591},">=",[581,1138,1139],{"class":650}," 500",[581,1141,1142],{"class":591},",\n",[581,1144,1145,1147],{"class":583,"line":621},[581,1146,797],{"class":591},[581,1148,656],{"class":595},[707,1150,1152],{"id":1151},"default-singleton","Default singleton",[481,1154,1155,1156,1159],{},"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,1157,1158],{"href":318},"stream server"," on the other — use the singleton accessors:",[572,1161,1163],{"className":574,"code":1162,"language":576,"meta":577,"style":577},"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,1164,1165,1189,1193,1198,1222,1226,1231],{"__ignoreMap":577},[581,1166,1167,1169,1171,1174,1176,1179,1181,1183,1185,1187],{"class":583,"line":584},[581,1168,588],{"class":587},[581,1170,592],{"class":591},[581,1172,1173],{"class":595}," getDefaultStream",[581,1175,697],{"class":591},[581,1177,1178],{"class":595}," setDefaultStream",[581,1180,599],{"class":591},[581,1182,602],{"class":587},[581,1184,605],{"class":591},[581,1186,510],{"class":608},[581,1188,611],{"class":591},[581,1190,1191],{"class":583,"line":614},[581,1192,618],{"emptyLinePlaceholder":617},[581,1194,1195],{"class":583,"line":621},[581,1196,1197],{"class":667},"\u002F\u002F Lazily creates a singleton on first call\n",[581,1199,1200,1202,1204,1206,1208,1210,1212,1214,1216,1218,1220],{"class":583,"line":659},[581,1201,625],{"class":624},[581,1203,628],{"class":595},[581,1205,631],{"class":591},[581,1207,1173],{"class":634},[581,1209,637],{"class":595},[581,1211,640],{"class":591},[581,1213,644],{"class":643},[581,1215,647],{"class":591},[581,1217,1139],{"class":650},[581,1219,599],{"class":591},[581,1221,656],{"class":595},[581,1223,1224],{"class":583,"line":664},[581,1225,618],{"emptyLinePlaceholder":617},[581,1227,1228],{"class":583,"line":671},[581,1229,1230],{"class":667},"\u002F\u002F Reset (mostly useful in tests)\n",[581,1232,1234,1237,1239,1242],{"class":583,"line":1233},7,[581,1235,1236],{"class":634},"setDefaultStream",[581,1238,637],{"class":595},[581,1240,1241],{"class":591},"null",[581,1243,656],{"class":595},[481,1245,1246,1247,1249,1250,1253],{},"The mini ",[477,1248,1158],{"href":318}," uses this singleton internally, so anything draining into ",[472,1251,1252],{},"getDefaultStream()"," automatically reaches all SSE clients.",[707,1255,1257],{"id":1256},"going-further","Going further",[499,1259,1260,1268],{},[502,1261,1262,1265,1266,479],{},[463,1263,1264],{},"Network bridge"," — expose this stream over HTTP for browser tabs \u002F CLIs \u002F external devtools. See the ",[477,1267,317],{"href":318},[502,1269,1270,1272,1273,479],{},[463,1271,156],{}," — concrete consumer patterns (devtool, replay-then-live, aggregation). See ",[477,1274,1275],{"href":327},"Consumer recipes",[1277,1278,1279],"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":577,"searchDepth":614,"depth":614,"links":1281},[1282,1286,1287,1288,1289,1290],{"id":709,"depth":614,"text":710,"children":1283},[1284,1285],{"id":717,"depth":621,"text":718},{"id":822,"depth":621,"text":823},{"id":945,"depth":614,"text":946},{"id":1058,"depth":614,"text":1059},{"id":1069,"depth":614,"text":1070},{"id":1151,"depth":614,"text":1152},{"id":1256,"depth":614,"text":1257},"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":1291},"egxiTln626dZdeD-SXjLtQcWeKg12rvO5Cc0-sfRTOE",[1299,1301],{"title":41,"path":295,"stem":296,"description":1300,"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":1302,"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.",1778340942644]