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