lograil 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/LICENSE +21 -0
- package/README.md +40 -0
- package/dist/cjs/context/async-context.browser.d.ts +16 -0
- package/dist/cjs/context/async-context.browser.d.ts.map +1 -0
- package/dist/cjs/context/async-context.browser.js +29 -0
- package/dist/cjs/context/async-context.browser.js.map +1 -0
- package/dist/cjs/context/async-context.d.ts +10 -0
- package/dist/cjs/context/async-context.d.ts.map +1 -0
- package/dist/cjs/context/async-context.js +37 -0
- package/dist/cjs/context/async-context.js.map +1 -0
- package/dist/cjs/context/context.d.ts +33 -0
- package/dist/cjs/context/context.d.ts.map +1 -0
- package/dist/cjs/context/context.js +57 -0
- package/dist/cjs/context/context.js.map +1 -0
- package/dist/cjs/context/index.d.ts +3 -0
- package/dist/cjs/context/index.d.ts.map +1 -0
- package/dist/cjs/context/index.js +19 -0
- package/dist/cjs/context/index.js.map +1 -0
- package/dist/cjs/core/entry.d.ts +30 -0
- package/dist/cjs/core/entry.d.ts.map +1 -0
- package/dist/cjs/core/entry.js +37 -0
- package/dist/cjs/core/entry.js.map +1 -0
- package/dist/cjs/core/index.d.ts +7 -0
- package/dist/cjs/core/index.d.ts.map +1 -0
- package/dist/cjs/core/index.js +24 -0
- package/dist/cjs/core/index.js.map +1 -0
- package/dist/cjs/core/level.d.ts +12 -0
- package/dist/cjs/core/level.d.ts.map +1 -0
- package/dist/cjs/core/level.js +31 -0
- package/dist/cjs/core/level.js.map +1 -0
- package/dist/cjs/core/logger.d.ts +271 -0
- package/dist/cjs/core/logger.d.ts.map +1 -0
- package/dist/cjs/core/logger.js +751 -0
- package/dist/cjs/core/logger.js.map +1 -0
- package/dist/cjs/core/printf.d.ts +34 -0
- package/dist/cjs/core/printf.d.ts.map +1 -0
- package/dist/cjs/core/printf.js +133 -0
- package/dist/cjs/core/printf.js.map +1 -0
- package/dist/cjs/index.d.ts +40 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +56 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/pipeline/filter.d.ts +10 -0
- package/dist/cjs/pipeline/filter.d.ts.map +1 -0
- package/dist/cjs/pipeline/filter.js +16 -0
- package/dist/cjs/pipeline/filter.js.map +1 -0
- package/dist/cjs/pipeline/formatter.d.ts +19 -0
- package/dist/cjs/pipeline/formatter.d.ts.map +1 -0
- package/dist/cjs/pipeline/formatter.js +183 -0
- package/dist/cjs/pipeline/formatter.js.map +1 -0
- package/dist/cjs/pipeline/index.d.ts +6 -0
- package/dist/cjs/pipeline/index.d.ts.map +1 -0
- package/dist/cjs/pipeline/index.js +22 -0
- package/dist/cjs/pipeline/index.js.map +1 -0
- package/dist/cjs/pipeline/pipeline.d.ts +45 -0
- package/dist/cjs/pipeline/pipeline.d.ts.map +1 -0
- package/dist/cjs/pipeline/pipeline.js +80 -0
- package/dist/cjs/pipeline/pipeline.js.map +1 -0
- package/dist/cjs/pipeline/processor.d.ts +67 -0
- package/dist/cjs/pipeline/processor.d.ts.map +1 -0
- package/dist/cjs/pipeline/processor.js +284 -0
- package/dist/cjs/pipeline/processor.js.map +1 -0
- package/dist/cjs/pipeline/sampler.d.ts +45 -0
- package/dist/cjs/pipeline/sampler.d.ts.map +1 -0
- package/dist/cjs/pipeline/sampler.js +62 -0
- package/dist/cjs/pipeline/sampler.js.map +1 -0
- package/dist/cjs/plugin/index.d.ts +4 -0
- package/dist/cjs/plugin/index.d.ts.map +1 -0
- package/dist/cjs/plugin/index.js +20 -0
- package/dist/cjs/plugin/index.js.map +1 -0
- package/dist/cjs/plugin/manager.d.ts +38 -0
- package/dist/cjs/plugin/manager.d.ts.map +1 -0
- package/dist/cjs/plugin/manager.js +79 -0
- package/dist/cjs/plugin/manager.js.map +1 -0
- package/dist/cjs/plugin/otel-trace.d.ts +19 -0
- package/dist/cjs/plugin/otel-trace.d.ts.map +1 -0
- package/dist/cjs/plugin/otel-trace.js +91 -0
- package/dist/cjs/plugin/otel-trace.js.map +1 -0
- package/dist/cjs/plugin/plugin.d.ts +41 -0
- package/dist/cjs/plugin/plugin.d.ts.map +1 -0
- package/dist/cjs/plugin/plugin.js +3 -0
- package/dist/cjs/plugin/plugin.js.map +1 -0
- package/dist/cjs/runtime/adapter.d.ts +81 -0
- package/dist/cjs/runtime/adapter.d.ts.map +1 -0
- package/dist/cjs/runtime/adapter.js +3 -0
- package/dist/cjs/runtime/adapter.js.map +1 -0
- package/dist/cjs/runtime/defaults.d.ts +27 -0
- package/dist/cjs/runtime/defaults.d.ts.map +1 -0
- package/dist/cjs/runtime/defaults.js +30 -0
- package/dist/cjs/runtime/defaults.js.map +1 -0
- package/dist/cjs/runtime/electron-binding.browser.d.ts +10 -0
- package/dist/cjs/runtime/electron-binding.browser.d.ts.map +1 -0
- package/dist/cjs/runtime/electron-binding.browser.js +18 -0
- package/dist/cjs/runtime/electron-binding.browser.js.map +1 -0
- package/dist/cjs/runtime/electron-binding.d.ts +24 -0
- package/dist/cjs/runtime/electron-binding.d.ts.map +1 -0
- package/dist/cjs/runtime/electron-binding.js +49 -0
- package/dist/cjs/runtime/electron-binding.js.map +1 -0
- package/dist/cjs/runtime/electron-lifecycle.d.ts +17 -0
- package/dist/cjs/runtime/electron-lifecycle.d.ts.map +1 -0
- package/dist/cjs/runtime/electron-lifecycle.js +47 -0
- package/dist/cjs/runtime/electron-lifecycle.js.map +1 -0
- package/dist/cjs/runtime/electron-main.d.ts +24 -0
- package/dist/cjs/runtime/electron-main.d.ts.map +1 -0
- package/dist/cjs/runtime/electron-main.js +102 -0
- package/dist/cjs/runtime/electron-main.js.map +1 -0
- package/dist/cjs/runtime/electron-renderer.d.ts +26 -0
- package/dist/cjs/runtime/electron-renderer.d.ts.map +1 -0
- package/dist/cjs/runtime/electron-renderer.js +33 -0
- package/dist/cjs/runtime/electron-renderer.js.map +1 -0
- package/dist/cjs/runtime/electron.d.ts +20 -0
- package/dist/cjs/runtime/electron.d.ts.map +1 -0
- package/dist/cjs/runtime/electron.js +27 -0
- package/dist/cjs/runtime/electron.js.map +1 -0
- package/dist/cjs/runtime/index.d.ts +21 -0
- package/dist/cjs/runtime/index.d.ts.map +1 -0
- package/dist/cjs/runtime/index.js +41 -0
- package/dist/cjs/runtime/index.js.map +1 -0
- package/dist/cjs/runtime/node.d.ts +27 -0
- package/dist/cjs/runtime/node.d.ts.map +1 -0
- package/dist/cjs/runtime/node.js +126 -0
- package/dist/cjs/runtime/node.js.map +1 -0
- package/dist/cjs/runtime/process-lifecycle.d.ts +13 -0
- package/dist/cjs/runtime/process-lifecycle.d.ts.map +1 -0
- package/dist/cjs/runtime/process-lifecycle.js +80 -0
- package/dist/cjs/runtime/process-lifecycle.js.map +1 -0
- package/dist/cjs/runtime/web-lifecycle.d.ts +13 -0
- package/dist/cjs/runtime/web-lifecycle.d.ts.map +1 -0
- package/dist/cjs/runtime/web-lifecycle.js +39 -0
- package/dist/cjs/runtime/web-lifecycle.js.map +1 -0
- package/dist/cjs/runtime/web.d.ts +14 -0
- package/dist/cjs/runtime/web.d.ts.map +1 -0
- package/dist/cjs/runtime/web.js +61 -0
- package/dist/cjs/runtime/web.js.map +1 -0
- package/dist/cjs/shims/index.browser.d.ts +26 -0
- package/dist/cjs/shims/index.browser.d.ts.map +1 -0
- package/dist/cjs/shims/index.browser.js +67 -0
- package/dist/cjs/shims/index.browser.js.map +1 -0
- package/dist/cjs/shims/index.d.ts +15 -0
- package/dist/cjs/shims/index.d.ts.map +1 -0
- package/dist/cjs/shims/index.js +39 -0
- package/dist/cjs/shims/index.js.map +1 -0
- package/dist/cjs/transport/cluster-ipc.d.ts +36 -0
- package/dist/cjs/transport/cluster-ipc.d.ts.map +1 -0
- package/dist/cjs/transport/cluster-ipc.js +76 -0
- package/dist/cjs/transport/cluster-ipc.js.map +1 -0
- package/dist/cjs/transport/console.d.ts +28 -0
- package/dist/cjs/transport/console.d.ts.map +1 -0
- package/dist/cjs/transport/console.js +48 -0
- package/dist/cjs/transport/console.js.map +1 -0
- package/dist/cjs/transport/electron-ipc.d.ts +69 -0
- package/dist/cjs/transport/electron-ipc.d.ts.map +1 -0
- package/dist/cjs/transport/electron-ipc.js +153 -0
- package/dist/cjs/transport/electron-ipc.js.map +1 -0
- package/dist/cjs/transport/file.d.ts +190 -0
- package/dist/cjs/transport/file.d.ts.map +1 -0
- package/dist/cjs/transport/file.js +666 -0
- package/dist/cjs/transport/file.js.map +1 -0
- package/dist/cjs/transport/index.d.ts +9 -0
- package/dist/cjs/transport/index.d.ts.map +1 -0
- package/dist/cjs/transport/index.js +25 -0
- package/dist/cjs/transport/index.js.map +1 -0
- package/dist/cjs/transport/live.d.ts +72 -0
- package/dist/cjs/transport/live.d.ts.map +1 -0
- package/dist/cjs/transport/live.js +104 -0
- package/dist/cjs/transport/live.js.map +1 -0
- package/dist/cjs/transport/otlp.d.ts +97 -0
- package/dist/cjs/transport/otlp.d.ts.map +1 -0
- package/dist/cjs/transport/otlp.js +194 -0
- package/dist/cjs/transport/otlp.js.map +1 -0
- package/dist/cjs/transport/rotating-file.d.ts +67 -0
- package/dist/cjs/transport/rotating-file.d.ts.map +1 -0
- package/dist/cjs/transport/rotating-file.js +179 -0
- package/dist/cjs/transport/rotating-file.js.map +1 -0
- package/dist/cjs/transport/transport.d.ts +35 -0
- package/dist/cjs/transport/transport.d.ts.map +1 -0
- package/dist/cjs/transport/transport.js +3 -0
- package/dist/cjs/transport/transport.js.map +1 -0
- package/dist/cjs/transport/worker-ipc.d.ts +43 -0
- package/dist/cjs/transport/worker-ipc.d.ts.map +1 -0
- package/dist/cjs/transport/worker-ipc.js +106 -0
- package/dist/cjs/transport/worker-ipc.js.map +1 -0
- package/dist/cjs/types.d.ts +72 -0
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/cjs/types.js +45 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/context/async-context.browser.d.ts +16 -0
- package/dist/esm/context/async-context.browser.d.ts.map +1 -0
- package/dist/esm/context/async-context.browser.js +25 -0
- package/dist/esm/context/async-context.browser.js.map +1 -0
- package/dist/esm/context/async-context.d.ts +10 -0
- package/dist/esm/context/async-context.d.ts.map +1 -0
- package/dist/esm/context/async-context.js +33 -0
- package/dist/esm/context/async-context.js.map +1 -0
- package/dist/esm/context/context.d.ts +33 -0
- package/dist/esm/context/context.d.ts.map +1 -0
- package/dist/esm/context/context.js +52 -0
- package/dist/esm/context/context.js.map +1 -0
- package/dist/esm/context/index.d.ts +3 -0
- package/dist/esm/context/index.d.ts.map +1 -0
- package/dist/esm/context/index.js +3 -0
- package/dist/esm/context/index.js.map +1 -0
- package/dist/esm/core/entry.d.ts +30 -0
- package/dist/esm/core/entry.d.ts.map +1 -0
- package/dist/esm/core/entry.js +34 -0
- package/dist/esm/core/entry.js.map +1 -0
- package/dist/esm/core/index.d.ts +7 -0
- package/dist/esm/core/index.d.ts.map +1 -0
- package/dist/esm/core/index.js +6 -0
- package/dist/esm/core/index.js.map +1 -0
- package/dist/esm/core/level.d.ts +12 -0
- package/dist/esm/core/level.d.ts.map +1 -0
- package/dist/esm/core/level.js +25 -0
- package/dist/esm/core/level.js.map +1 -0
- package/dist/esm/core/logger.d.ts +271 -0
- package/dist/esm/core/logger.d.ts.map +1 -0
- package/dist/esm/core/logger.js +747 -0
- package/dist/esm/core/logger.js.map +1 -0
- package/dist/esm/core/printf.d.ts +34 -0
- package/dist/esm/core/printf.d.ts.map +1 -0
- package/dist/esm/core/printf.js +129 -0
- package/dist/esm/core/printf.js.map +1 -0
- package/dist/esm/index.d.ts +40 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +38 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/pipeline/filter.d.ts +10 -0
- package/dist/esm/pipeline/filter.d.ts.map +1 -0
- package/dist/esm/pipeline/filter.js +11 -0
- package/dist/esm/pipeline/filter.js.map +1 -0
- package/dist/esm/pipeline/formatter.d.ts +19 -0
- package/dist/esm/pipeline/formatter.d.ts.map +1 -0
- package/dist/esm/pipeline/formatter.js +179 -0
- package/dist/esm/pipeline/formatter.js.map +1 -0
- package/dist/esm/pipeline/index.d.ts +6 -0
- package/dist/esm/pipeline/index.d.ts.map +1 -0
- package/dist/esm/pipeline/index.js +6 -0
- package/dist/esm/pipeline/index.js.map +1 -0
- package/dist/esm/pipeline/pipeline.d.ts +45 -0
- package/dist/esm/pipeline/pipeline.d.ts.map +1 -0
- package/dist/esm/pipeline/pipeline.js +76 -0
- package/dist/esm/pipeline/pipeline.js.map +1 -0
- package/dist/esm/pipeline/processor.d.ts +67 -0
- package/dist/esm/pipeline/processor.d.ts.map +1 -0
- package/dist/esm/pipeline/processor.js +277 -0
- package/dist/esm/pipeline/processor.js.map +1 -0
- package/dist/esm/pipeline/sampler.d.ts +45 -0
- package/dist/esm/pipeline/sampler.d.ts.map +1 -0
- package/dist/esm/pipeline/sampler.js +59 -0
- package/dist/esm/pipeline/sampler.js.map +1 -0
- package/dist/esm/plugin/index.d.ts +4 -0
- package/dist/esm/plugin/index.d.ts.map +1 -0
- package/dist/esm/plugin/index.js +4 -0
- package/dist/esm/plugin/index.js.map +1 -0
- package/dist/esm/plugin/manager.d.ts +38 -0
- package/dist/esm/plugin/manager.d.ts.map +1 -0
- package/dist/esm/plugin/manager.js +75 -0
- package/dist/esm/plugin/manager.js.map +1 -0
- package/dist/esm/plugin/otel-trace.d.ts +19 -0
- package/dist/esm/plugin/otel-trace.d.ts.map +1 -0
- package/dist/esm/plugin/otel-trace.js +55 -0
- package/dist/esm/plugin/otel-trace.js.map +1 -0
- package/dist/esm/plugin/plugin.d.ts +41 -0
- package/dist/esm/plugin/plugin.d.ts.map +1 -0
- package/dist/esm/plugin/plugin.js +2 -0
- package/dist/esm/plugin/plugin.js.map +1 -0
- package/dist/esm/runtime/adapter.d.ts +81 -0
- package/dist/esm/runtime/adapter.d.ts.map +1 -0
- package/dist/esm/runtime/adapter.js +2 -0
- package/dist/esm/runtime/adapter.js.map +1 -0
- package/dist/esm/runtime/defaults.d.ts +27 -0
- package/dist/esm/runtime/defaults.d.ts.map +1 -0
- package/dist/esm/runtime/defaults.js +27 -0
- package/dist/esm/runtime/defaults.js.map +1 -0
- package/dist/esm/runtime/electron-binding.browser.d.ts +10 -0
- package/dist/esm/runtime/electron-binding.browser.d.ts.map +1 -0
- package/dist/esm/runtime/electron-binding.browser.js +13 -0
- package/dist/esm/runtime/electron-binding.browser.js.map +1 -0
- package/dist/esm/runtime/electron-binding.d.ts +24 -0
- package/dist/esm/runtime/electron-binding.d.ts.map +1 -0
- package/dist/esm/runtime/electron-binding.js +44 -0
- package/dist/esm/runtime/electron-binding.js.map +1 -0
- package/dist/esm/runtime/electron-lifecycle.d.ts +17 -0
- package/dist/esm/runtime/electron-lifecycle.d.ts.map +1 -0
- package/dist/esm/runtime/electron-lifecycle.js +44 -0
- package/dist/esm/runtime/electron-lifecycle.js.map +1 -0
- package/dist/esm/runtime/electron-main.d.ts +24 -0
- package/dist/esm/runtime/electron-main.d.ts.map +1 -0
- package/dist/esm/runtime/electron-main.js +99 -0
- package/dist/esm/runtime/electron-main.js.map +1 -0
- package/dist/esm/runtime/electron-renderer.d.ts +26 -0
- package/dist/esm/runtime/electron-renderer.d.ts.map +1 -0
- package/dist/esm/runtime/electron-renderer.js +30 -0
- package/dist/esm/runtime/electron-renderer.js.map +1 -0
- package/dist/esm/runtime/electron.d.ts +20 -0
- package/dist/esm/runtime/electron.d.ts.map +1 -0
- package/dist/esm/runtime/electron.js +21 -0
- package/dist/esm/runtime/electron.js.map +1 -0
- package/dist/esm/runtime/index.d.ts +21 -0
- package/dist/esm/runtime/index.d.ts.map +1 -0
- package/dist/esm/runtime/index.js +29 -0
- package/dist/esm/runtime/index.js.map +1 -0
- package/dist/esm/runtime/node.d.ts +27 -0
- package/dist/esm/runtime/node.d.ts.map +1 -0
- package/dist/esm/runtime/node.js +123 -0
- package/dist/esm/runtime/node.js.map +1 -0
- package/dist/esm/runtime/process-lifecycle.d.ts +13 -0
- package/dist/esm/runtime/process-lifecycle.d.ts.map +1 -0
- package/dist/esm/runtime/process-lifecycle.js +77 -0
- package/dist/esm/runtime/process-lifecycle.js.map +1 -0
- package/dist/esm/runtime/web-lifecycle.d.ts +13 -0
- package/dist/esm/runtime/web-lifecycle.d.ts.map +1 -0
- package/dist/esm/runtime/web-lifecycle.js +36 -0
- package/dist/esm/runtime/web-lifecycle.js.map +1 -0
- package/dist/esm/runtime/web.d.ts +14 -0
- package/dist/esm/runtime/web.d.ts.map +1 -0
- package/dist/esm/runtime/web.js +58 -0
- package/dist/esm/runtime/web.js.map +1 -0
- package/dist/esm/shims/index.browser.d.ts +26 -0
- package/dist/esm/shims/index.browser.d.ts.map +1 -0
- package/dist/esm/shims/index.browser.js +54 -0
- package/dist/esm/shims/index.browser.js.map +1 -0
- package/dist/esm/shims/index.d.ts +15 -0
- package/dist/esm/shims/index.d.ts.map +1 -0
- package/dist/esm/shims/index.js +22 -0
- package/dist/esm/shims/index.js.map +1 -0
- package/dist/esm/transport/cluster-ipc.d.ts +36 -0
- package/dist/esm/transport/cluster-ipc.d.ts.map +1 -0
- package/dist/esm/transport/cluster-ipc.js +71 -0
- package/dist/esm/transport/cluster-ipc.js.map +1 -0
- package/dist/esm/transport/console.d.ts +28 -0
- package/dist/esm/transport/console.d.ts.map +1 -0
- package/dist/esm/transport/console.js +44 -0
- package/dist/esm/transport/console.js.map +1 -0
- package/dist/esm/transport/electron-ipc.d.ts +69 -0
- package/dist/esm/transport/electron-ipc.d.ts.map +1 -0
- package/dist/esm/transport/electron-ipc.js +146 -0
- package/dist/esm/transport/electron-ipc.js.map +1 -0
- package/dist/esm/transport/file.d.ts +190 -0
- package/dist/esm/transport/file.d.ts.map +1 -0
- package/dist/esm/transport/file.js +662 -0
- package/dist/esm/transport/file.js.map +1 -0
- package/dist/esm/transport/index.d.ts +9 -0
- package/dist/esm/transport/index.d.ts.map +1 -0
- package/dist/esm/transport/index.js +9 -0
- package/dist/esm/transport/index.js.map +1 -0
- package/dist/esm/transport/live.d.ts +72 -0
- package/dist/esm/transport/live.d.ts.map +1 -0
- package/dist/esm/transport/live.js +100 -0
- package/dist/esm/transport/live.js.map +1 -0
- package/dist/esm/transport/otlp.d.ts +97 -0
- package/dist/esm/transport/otlp.d.ts.map +1 -0
- package/dist/esm/transport/otlp.js +190 -0
- package/dist/esm/transport/otlp.js.map +1 -0
- package/dist/esm/transport/rotating-file.d.ts +67 -0
- package/dist/esm/transport/rotating-file.d.ts.map +1 -0
- package/dist/esm/transport/rotating-file.js +175 -0
- package/dist/esm/transport/rotating-file.js.map +1 -0
- package/dist/esm/transport/transport.d.ts +35 -0
- package/dist/esm/transport/transport.d.ts.map +1 -0
- package/dist/esm/transport/transport.js +2 -0
- package/dist/esm/transport/transport.js.map +1 -0
- package/dist/esm/transport/worker-ipc.d.ts +43 -0
- package/dist/esm/transport/worker-ipc.d.ts.map +1 -0
- package/dist/esm/transport/worker-ipc.js +101 -0
- package/dist/esm/transport/worker-ipc.js.map +1 -0
- package/dist/esm/types.d.ts +72 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +39 -0
- package/dist/esm/types.js.map +1 -0
- package/package.json +128 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { LogEntry } from '../types.js';
|
|
2
|
+
import type { Formatter } from '../pipeline/formatter.js';
|
|
3
|
+
import type { Transport } from './transport.js';
|
|
4
|
+
export interface RotatingFileTransportOptions {
|
|
5
|
+
/** Active (or current-day) log file path, e.g. `/var/log/app.log`. */
|
|
6
|
+
path: string;
|
|
7
|
+
/** Size mode: rotate once the active file exceeds this size in bytes. */
|
|
8
|
+
maxSize?: number;
|
|
9
|
+
/**
|
|
10
|
+
* Maximum number of files in the rotation set.
|
|
11
|
+
* - Size mode: `app.log` + `app.1.log` … (generations). Minimum 2.
|
|
12
|
+
* - Daily mode: `{name}.{YYYY-MM-DD}.01..{maxFiles}.log` per day; when the
|
|
13
|
+
* index would pass `maxFiles` it wraps back to `01` and clears that file.
|
|
14
|
+
* Defaults to 5 (size) or 99 (daily).
|
|
15
|
+
*/
|
|
16
|
+
maxFiles?: number;
|
|
17
|
+
/**
|
|
18
|
+
* Daily mode (default `true`): one dated file per day, split into
|
|
19
|
+
* `01`..`{maxFiles}` indexes. Set `false` for plain size-based generation
|
|
20
|
+
* rotation (`app.log` → `app.1.log` → …) without dates.
|
|
21
|
+
*/
|
|
22
|
+
daily?: boolean;
|
|
23
|
+
/** Override the clock (mainly for testing). Defaults to `new Date()`. */
|
|
24
|
+
now?: () => Date;
|
|
25
|
+
formatter?: Formatter;
|
|
26
|
+
name?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* File transport with rotation, for the Electron main process (Node.js).
|
|
30
|
+
*
|
|
31
|
+
* Two modes:
|
|
32
|
+
* - **Daily** (default): the active file is
|
|
33
|
+
* `{name}.{YYYY-MM-DD}.{index}.log`, where `index` runs `01`..`maxFiles`
|
|
34
|
+
* (default 99). When it would pass `maxFiles` it wraps back to `01` and
|
|
35
|
+
* that file is cleared — a `maxFiles`-file ring buffer per day. When the
|
|
36
|
+
* local day changes, the index resets to `01` for the new day.
|
|
37
|
+
*/
|
|
38
|
+
export declare class RotatingFileTransport implements Transport {
|
|
39
|
+
readonly name: string;
|
|
40
|
+
readonly formatter: Formatter;
|
|
41
|
+
private readonly path;
|
|
42
|
+
private readonly maxSize;
|
|
43
|
+
private readonly maxFiles;
|
|
44
|
+
private readonly daily;
|
|
45
|
+
private readonly now;
|
|
46
|
+
private handle;
|
|
47
|
+
private queue;
|
|
48
|
+
private size;
|
|
49
|
+
private sizeInitialized;
|
|
50
|
+
private currentDate;
|
|
51
|
+
private index;
|
|
52
|
+
constructor(options: RotatingFileTransportOptions);
|
|
53
|
+
private activePath;
|
|
54
|
+
private ensureHandle;
|
|
55
|
+
private ensureSize;
|
|
56
|
+
private rotateSize;
|
|
57
|
+
/**
|
|
58
|
+
* Move to a new index file. When `clear` is true the target file is
|
|
59
|
+
* truncated first (used both for normal index advancement and for the
|
|
60
|
+
* wrap-to-01, which must clear the stale `01` slot).
|
|
61
|
+
*/
|
|
62
|
+
private rotateToIndex;
|
|
63
|
+
write(_entry: LogEntry, formatted: string): void | Promise<void>;
|
|
64
|
+
flush(): Promise<void>;
|
|
65
|
+
close(): Promise<void>;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=rotating-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rotating-file.d.ts","sourceRoot":"","sources":["../../../src/transport/rotating-file.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,WAAW,4BAA4B;IAC3C,sEAAsE;IACtE,IAAI,EAAE,MAAM,CAAC;IACb,yEAAyE;IACzE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,yEAAyE;IACzE,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;IACjB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAaD;;;;;;;;;GASG;AACH,qBAAa,qBAAsB,YAAW,SAAS;IACrD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAU;IAChC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAa;IACjC,OAAO,CAAC,MAAM,CAAiD;IAC/D,OAAO,CAAC,KAAK,CAAoC;IACjD,OAAO,CAAC,IAAI,CAAK;IACjB,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,WAAW,CAAqB;IACxC,OAAO,CAAC,KAAK,CAAK;gBAEN,OAAO,EAAE,4BAA4B;IAkBjD,OAAO,CAAC,UAAU;YAUJ,YAAY;YAOZ,UAAU;YAWV,UAAU;IAuBxB;;;;OAIG;YACW,aAAa;IAqB3B,KAAK,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAuC1D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAItB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAO7B"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RotatingFileTransport = void 0;
|
|
4
|
+
const promises_1 = require("node:fs/promises");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
const formatter_js_1 = require("../pipeline/formatter.js");
|
|
7
|
+
const DEFAULT_MAX_SIZE = 10 * 1024 * 1024;
|
|
8
|
+
const DEFAULT_MAX_FILES = 5;
|
|
9
|
+
const DEFAULT_MAX_FILES_DAILY = 99;
|
|
10
|
+
function dateStamp(d) {
|
|
11
|
+
const y = d.getFullYear();
|
|
12
|
+
const m = String(d.getMonth() + 1).padStart(2, '0');
|
|
13
|
+
const day = String(d.getDate()).padStart(2, '0');
|
|
14
|
+
return `${y}-${m}-${day}`;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* File transport with rotation, for the Electron main process (Node.js).
|
|
18
|
+
*
|
|
19
|
+
* Two modes:
|
|
20
|
+
* - **Daily** (default): the active file is
|
|
21
|
+
* `{name}.{YYYY-MM-DD}.{index}.log`, where `index` runs `01`..`maxFiles`
|
|
22
|
+
* (default 99). When it would pass `maxFiles` it wraps back to `01` and
|
|
23
|
+
* that file is cleared — a `maxFiles`-file ring buffer per day. When the
|
|
24
|
+
* local day changes, the index resets to `01` for the new day.
|
|
25
|
+
*/
|
|
26
|
+
class RotatingFileTransport {
|
|
27
|
+
constructor(options) {
|
|
28
|
+
this.handle = null;
|
|
29
|
+
this.queue = Promise.resolve();
|
|
30
|
+
this.size = 0;
|
|
31
|
+
this.sizeInitialized = false;
|
|
32
|
+
this.index = 1;
|
|
33
|
+
if (!options.path) {
|
|
34
|
+
throw new Error('RotatingFileTransport requires a "path"');
|
|
35
|
+
}
|
|
36
|
+
this.path = options.path;
|
|
37
|
+
this.daily = options.daily ?? true;
|
|
38
|
+
this.maxSize = options.maxSize ?? DEFAULT_MAX_SIZE;
|
|
39
|
+
this.maxFiles = options.maxFiles ?? (this.daily ? DEFAULT_MAX_FILES_DAILY : DEFAULT_MAX_FILES);
|
|
40
|
+
if (!this.daily) {
|
|
41
|
+
this.maxFiles = Math.max(2, this.maxFiles);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
this.maxFiles = Math.max(1, this.maxFiles);
|
|
45
|
+
}
|
|
46
|
+
this.now = options.now ?? (() => new Date());
|
|
47
|
+
this.name = options.name ?? `rotating-file:${options.path}`;
|
|
48
|
+
this.formatter = options.formatter ?? (0, formatter_js_1.createJsonFormatter)();
|
|
49
|
+
}
|
|
50
|
+
activePath() {
|
|
51
|
+
if (!this.daily) {
|
|
52
|
+
return this.path;
|
|
53
|
+
}
|
|
54
|
+
const ext = (0, node_path_1.extname)(this.path);
|
|
55
|
+
const base = ext ? this.path.slice(0, -ext.length) : this.path;
|
|
56
|
+
const idx = String(this.index).padStart(2, '0');
|
|
57
|
+
return `${base}.${this.currentDate}.${idx}${ext}`;
|
|
58
|
+
}
|
|
59
|
+
async ensureHandle() {
|
|
60
|
+
if (!this.handle) {
|
|
61
|
+
await (0, promises_1.mkdir)((0, node_path_1.dirname)(this.activePath()), { recursive: true });
|
|
62
|
+
this.handle = await (0, promises_1.open)(this.activePath(), 'a');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
async ensureSize() {
|
|
66
|
+
if (this.sizeInitialized)
|
|
67
|
+
return;
|
|
68
|
+
try {
|
|
69
|
+
const st = await (0, promises_1.stat)(this.activePath());
|
|
70
|
+
this.size = st.size;
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
this.size = 0;
|
|
74
|
+
}
|
|
75
|
+
this.sizeInitialized = true;
|
|
76
|
+
}
|
|
77
|
+
async rotateSize() {
|
|
78
|
+
if (this.handle) {
|
|
79
|
+
await this.handle.close();
|
|
80
|
+
this.handle = null;
|
|
81
|
+
}
|
|
82
|
+
const gens = this.maxFiles - 1;
|
|
83
|
+
for (let k = gens; k >= 2; k--) {
|
|
84
|
+
try {
|
|
85
|
+
await (0, promises_1.rename)(`${this.path}.${k - 1}`, `${this.path}.${k}`);
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
/* generation missing — skip */
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
await (0, promises_1.rename)(this.path, `${this.path}.1`);
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
/* nothing to rotate yet */
|
|
96
|
+
}
|
|
97
|
+
this.size = 0;
|
|
98
|
+
this.sizeInitialized = true;
|
|
99
|
+
await this.ensureHandle();
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Move to a new index file. When `clear` is true the target file is
|
|
103
|
+
* truncated first (used both for normal index advancement and for the
|
|
104
|
+
* wrap-to-01, which must clear the stale `01` slot).
|
|
105
|
+
*/
|
|
106
|
+
async rotateToIndex(idx, clear) {
|
|
107
|
+
if (this.handle) {
|
|
108
|
+
await this.handle.close();
|
|
109
|
+
this.handle = null;
|
|
110
|
+
}
|
|
111
|
+
this.index = idx;
|
|
112
|
+
if (clear) {
|
|
113
|
+
try {
|
|
114
|
+
await (0, promises_1.truncate)(this.activePath(), 0);
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
/* file did not exist yet — fine */
|
|
118
|
+
}
|
|
119
|
+
this.size = 0;
|
|
120
|
+
this.sizeInitialized = true;
|
|
121
|
+
}
|
|
122
|
+
await this.ensureHandle();
|
|
123
|
+
if (!clear) {
|
|
124
|
+
await this.ensureSize();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
write(_entry, formatted) {
|
|
128
|
+
const line = formatted + '\n';
|
|
129
|
+
const bytes = Buffer.byteLength(line, 'utf8');
|
|
130
|
+
const task = this.queue
|
|
131
|
+
.then(async () => {
|
|
132
|
+
if (!this.daily) {
|
|
133
|
+
await this.ensureSize();
|
|
134
|
+
if (this.size + bytes > this.maxSize) {
|
|
135
|
+
await this.rotateSize();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
const today = dateStamp(this.now());
|
|
140
|
+
if (this.currentDate === undefined || today !== this.currentDate) {
|
|
141
|
+
// First open, or a new day: reset to index 01 (resume/append).
|
|
142
|
+
this.currentDate = today;
|
|
143
|
+
this.index = 1;
|
|
144
|
+
await this.rotateToIndex(1, false);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
await this.ensureSize();
|
|
148
|
+
if (this.size + bytes > this.maxSize) {
|
|
149
|
+
let next = this.index + 1;
|
|
150
|
+
if (next > this.maxFiles) {
|
|
151
|
+
next = 1; // wrap and clear the 01 slot
|
|
152
|
+
}
|
|
153
|
+
await this.rotateToIndex(next, true);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
await this.ensureHandle();
|
|
158
|
+
await this.handle.write(line);
|
|
159
|
+
this.size += bytes;
|
|
160
|
+
})
|
|
161
|
+
.catch(() => {
|
|
162
|
+
/* swallow write errors to avoid crashing the app */
|
|
163
|
+
});
|
|
164
|
+
this.queue = task;
|
|
165
|
+
return task;
|
|
166
|
+
}
|
|
167
|
+
async flush() {
|
|
168
|
+
await this.queue;
|
|
169
|
+
}
|
|
170
|
+
async close() {
|
|
171
|
+
await this.queue;
|
|
172
|
+
if (this.handle) {
|
|
173
|
+
await this.handle.close();
|
|
174
|
+
this.handle = null;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
exports.RotatingFileTransport = RotatingFileTransport;
|
|
179
|
+
//# sourceMappingURL=rotating-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rotating-file.js","sourceRoot":"","sources":["../../../src/transport/rotating-file.ts"],"names":[],"mappings":";;;AAAA,+CAAuE;AACvE,yCAA6C;AAG7C,2DAA+D;AA4B/D,MAAM,gBAAgB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAC1C,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAEnC,SAAS,SAAS,CAAC,CAAO;IACxB,MAAM,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;IAC1B,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACpD,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACjD,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;AAC5B,CAAC;AAED;;;;;;;;;GASG;AACH,MAAa,qBAAqB;IAehC,YAAY,OAAqC;QAPzC,WAAM,GAA4C,IAAI,CAAC;QACvD,UAAK,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAC;QACzC,SAAI,GAAG,CAAC,CAAC;QACT,oBAAe,GAAG,KAAK,CAAC;QAExB,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,CAAC;4BACzB,IAAI,GAAG,CAAC,CAAC,CAAC,6BAA6B;wBACzC,CAAC;wBACD,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;oBACvC,CAAC;gBACH,CAAC;YACH,CAAC;YACD,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;YAC1B,MAAM,IAAI,CAAC,MAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC/B,IAAI,CAAC,IAAI,IAAI,KAAK,CAAC;QACrB,CAAC,CAAC;aACD,KAAK,CAAC,GAAG,EAAE;YACV,oDAAoD;QACtD,CAAC,CAAC,CAAC;QACL,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,KAAK,CAAC;QACjB,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAC1B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACrB,CAAC;IACH,CAAC;CACF;AAhKD,sDAgKC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { LogEntry, LogLevelInput } from '../types.js';
|
|
2
|
+
import type { Formatter } from '../pipeline/formatter.js';
|
|
3
|
+
/**
|
|
4
|
+
* A Transport is the final sink of a log entry. Examples: console, file,
|
|
5
|
+
* IPC to the Electron main process, or HTTP remote reporting.
|
|
6
|
+
*
|
|
7
|
+
* `write` may be synchronous or async. When async, the Logger awaits it
|
|
8
|
+
* during a `flush()`.
|
|
9
|
+
*/
|
|
10
|
+
export interface Transport {
|
|
11
|
+
/** Unique transport name, used for diagnostics and removal. */
|
|
12
|
+
readonly name: string;
|
|
13
|
+
/** Optional per-transport formatter, overrides the pipeline default. */
|
|
14
|
+
readonly formatter?: Formatter;
|
|
15
|
+
/**
|
|
16
|
+
* Optional minimum level for this transport, as a name (`'info'`) or number.
|
|
17
|
+
* Entries below this level are skipped by this transport (the logger-level
|
|
18
|
+
* filter still applies first). Lets you route, e.g., `error`+ to a remote
|
|
19
|
+
* sink while sending everything to a file.
|
|
20
|
+
*/
|
|
21
|
+
readonly level?: LogLevelInput;
|
|
22
|
+
/** Emit a processed entry. */
|
|
23
|
+
write(entry: LogEntry, formatted: string): void | Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Optional hook invoked by the logger when `write` (or the promise it
|
|
26
|
+
* returns) fails, so a broken sink can be reported without throwing out of
|
|
27
|
+
* the caller's `log.*` call. The original entry is passed for context.
|
|
28
|
+
*/
|
|
29
|
+
onError?(err: unknown, entry: LogEntry): void;
|
|
30
|
+
/** Optional flush; awaited by `Logger.flush()`. */
|
|
31
|
+
flush?(): void | Promise<void>;
|
|
32
|
+
/** Optional teardown. */
|
|
33
|
+
close?(): void | Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../src/transport/transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAE1D;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACxB,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,wEAAwE;IACxE,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;IAC/B;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC;IAC/B,8BAA8B;IAC9B,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE;;;;OAIG;IACH,OAAO,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC9C,mDAAmD;IACnD,KAAK,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,yBAAyB;IACzB,KAAK,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../../src/transport/transport.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { LogEntry } from '../types.js';
|
|
2
|
+
import type { Transport } from './transport.js';
|
|
3
|
+
/** Minimal view of the `postMessage` function available in Web Workers and Node worker_threads. */
|
|
4
|
+
type PostMessageFn = (message: unknown, transfer?: unknown[]) => void;
|
|
5
|
+
/** Minimal view of a Worker-like target that can receive messages. */
|
|
6
|
+
type MessageTarget = {
|
|
7
|
+
postMessage: PostMessageFn;
|
|
8
|
+
};
|
|
9
|
+
export interface WorkerIpcTransportOptions {
|
|
10
|
+
/** Transport name. */
|
|
11
|
+
name?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Worker-side transport that sends entries to the main thread via
|
|
15
|
+
* `self.postMessage()`. Safe to import in non-Worker environments — the write
|
|
16
|
+
* call is a no-op when `self.postMessage` is unavailable.
|
|
17
|
+
*/
|
|
18
|
+
export declare class WorkerIpcTransport implements Transport {
|
|
19
|
+
readonly name: string;
|
|
20
|
+
constructor(options?: WorkerIpcTransportOptions);
|
|
21
|
+
write(entry: LogEntry, _formatted: string): void;
|
|
22
|
+
/** Send a cross-process level command to the main thread. */
|
|
23
|
+
sendLevelCommand(level: number): void;
|
|
24
|
+
}
|
|
25
|
+
export interface WorkerReceiverOptions {
|
|
26
|
+
/** Specific Worker instance to listen on. If omitted, listens on `self.onmessage` (shared worker / global). */
|
|
27
|
+
worker?: MessageTarget;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Main-thread helper: listen for worker entries and feed them into the
|
|
31
|
+
* provided `ingest` callback (typically `logger.ingestEntry`). Level-change
|
|
32
|
+
* commands are forwarded to `onLevelCommand` when provided.
|
|
33
|
+
* Returns an unregister function.
|
|
34
|
+
*
|
|
35
|
+
* Works with `Worker` instances (dedicated workers). For a specific worker
|
|
36
|
+
* pass `worker: myWorkerInstance`; otherwise listens on `self.onmessage`
|
|
37
|
+
* for shared-worker / broadcast-channel patterns.
|
|
38
|
+
*/
|
|
39
|
+
export declare function registerWorkerReceiver(ingest: (entry: LogEntry) => void, options?: WorkerReceiverOptions & {
|
|
40
|
+
onLevelCommand?: (level: number) => void;
|
|
41
|
+
}): () => void;
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=worker-ipc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-ipc.d.ts","sourceRoot":"","sources":["../../../src/transport/worker-ipc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAKhD,mGAAmG;AACnG,KAAK,aAAa,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;AAEtE,sEAAsE;AACtE,KAAK,aAAa,GAAG;IACnB,WAAW,EAAE,aAAa,CAAC;CAC5B,CAAC;AAEF,MAAM,WAAW,yBAAyB;IACxC,sBAAsB;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,qBAAa,kBAAmB,YAAW,SAAS;IAClD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,OAAO,GAAE,yBAA8B;IAInD,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI;IAWhD,6DAA6D;IAC7D,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;CAWtC;AAED,MAAM,WAAW,qBAAqB;IACpC,+GAA+G;IAC/G,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,EACjC,OAAO,GAAE,qBAAqB,GAAG;IAAE,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;CAAO,GACjF,MAAM,IAAI,CA8DZ"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkerIpcTransport = void 0;
|
|
4
|
+
exports.registerWorkerReceiver = registerWorkerReceiver;
|
|
5
|
+
const types_js_1 = require("../types.js");
|
|
6
|
+
const types_js_2 = require("../types.js");
|
|
7
|
+
/**
|
|
8
|
+
* Worker-side transport that sends entries to the main thread via
|
|
9
|
+
* `self.postMessage()`. Safe to import in non-Worker environments — the write
|
|
10
|
+
* call is a no-op when `self.postMessage` is unavailable.
|
|
11
|
+
*/
|
|
12
|
+
class WorkerIpcTransport {
|
|
13
|
+
constructor(options = {}) {
|
|
14
|
+
this.name = options.name ?? 'worker-ipc';
|
|
15
|
+
}
|
|
16
|
+
write(entry, _formatted) {
|
|
17
|
+
try {
|
|
18
|
+
const target = self;
|
|
19
|
+
if (typeof target.postMessage === 'function') {
|
|
20
|
+
target.postMessage({ __lograilWorker: true, entry });
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
/* postMessage unavailable or failed — drop silently */
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** Send a cross-process level command to the main thread. */
|
|
28
|
+
sendLevelCommand(level) {
|
|
29
|
+
try {
|
|
30
|
+
const target = self;
|
|
31
|
+
if (typeof target.postMessage === 'function') {
|
|
32
|
+
const cmd = { __lograilCmd: true, __lograilCmdType: 'setLevel', level };
|
|
33
|
+
target.postMessage(cmd);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
/* postMessage unavailable — drop silently */
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.WorkerIpcTransport = WorkerIpcTransport;
|
|
42
|
+
/**
|
|
43
|
+
* Main-thread helper: listen for worker entries and feed them into the
|
|
44
|
+
* provided `ingest` callback (typically `logger.ingestEntry`). Level-change
|
|
45
|
+
* commands are forwarded to `onLevelCommand` when provided.
|
|
46
|
+
* Returns an unregister function.
|
|
47
|
+
*
|
|
48
|
+
* Works with `Worker` instances (dedicated workers). For a specific worker
|
|
49
|
+
* pass `worker: myWorkerInstance`; otherwise listens on `self.onmessage`
|
|
50
|
+
* for shared-worker / broadcast-channel patterns.
|
|
51
|
+
*/
|
|
52
|
+
function registerWorkerReceiver(ingest, options = {}) {
|
|
53
|
+
const onLevelCommand = options.onLevelCommand;
|
|
54
|
+
const handler = (event) => {
|
|
55
|
+
const data = event.data;
|
|
56
|
+
if (data &&
|
|
57
|
+
typeof data === 'object' &&
|
|
58
|
+
'__lograilWorker' in data &&
|
|
59
|
+
data.__lograilWorker === true &&
|
|
60
|
+
'entry' in data) {
|
|
61
|
+
ingest(data.entry);
|
|
62
|
+
}
|
|
63
|
+
else if ((0, types_js_1.isLogLevelCommand)(data)) {
|
|
64
|
+
onLevelCommand?.((0, types_js_2.normalizeLevel)(data.level));
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const worker = options.worker;
|
|
68
|
+
if (worker && typeof worker === 'object') {
|
|
69
|
+
if ('on' in worker && typeof worker.on === 'function') {
|
|
70
|
+
// Node Worker instance — worker.on('message', handler)
|
|
71
|
+
// Node passes raw data (not MessageEvent), so adapt:
|
|
72
|
+
const nodeHandler = (data) => {
|
|
73
|
+
if (data &&
|
|
74
|
+
typeof data === 'object' &&
|
|
75
|
+
'__lograilWorker' in data &&
|
|
76
|
+
data.__lograilWorker === true &&
|
|
77
|
+
'entry' in data) {
|
|
78
|
+
ingest(data.entry);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
worker.on('message', nodeHandler);
|
|
82
|
+
return () => {
|
|
83
|
+
/* Node Worker doesn't support off(); callers should dispose the Worker */
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
if ('onmessage' in worker) {
|
|
87
|
+
// Web Worker — dedicated worker onmessage
|
|
88
|
+
worker.onmessage = handler;
|
|
89
|
+
return () => {
|
|
90
|
+
if (worker.onmessage === handler)
|
|
91
|
+
worker.onmessage = null;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// Global self.onmessage — shared worker / fallback
|
|
96
|
+
const prev = self.onmessage;
|
|
97
|
+
self.addEventListener('message', handler);
|
|
98
|
+
return () => {
|
|
99
|
+
self.removeEventListener('message', handler);
|
|
100
|
+
// Restore previous handler if it was there
|
|
101
|
+
if (self.onmessage === null && prev !== undefined) {
|
|
102
|
+
self.onmessage = prev;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=worker-ipc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-ipc.js","sourceRoot":"","sources":["../../../src/transport/worker-ipc.ts"],"names":[],"mappings":";;;AAuEA,wDAiEC;AArID,0CAAgD;AAChD,0CAA6C;AAe7C;;;;GAIG;AACH,MAAa,kBAAkB;IAG7B,YAAY,UAAqC,EAAE;QACjD,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,YAAY,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,KAAe,EAAE,UAAkB;QACvC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAgC,CAAC;YAChD,IA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,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared type definitions for the logging library.
|
|
3
|
+
*
|
|
4
|
+
* These types form the stable contract used across Core, Pipeline,
|
|
5
|
+
* Transport, Runtime and Plugin modules.
|
|
6
|
+
*/
|
|
7
|
+
export type LogLevelName = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';
|
|
8
|
+
export type LogLevelValue = number;
|
|
9
|
+
/**
|
|
10
|
+
* Ordered by severity. Higher value means more severe.
|
|
11
|
+
*/
|
|
12
|
+
export declare const LOG_LEVELS: Record<LogLevelName, LogLevelValue>;
|
|
13
|
+
export declare const LOG_LEVEL_NAMES: LogLevelName[];
|
|
14
|
+
export declare function isLogLevelName(value: unknown): value is LogLevelName;
|
|
15
|
+
/**
|
|
16
|
+
* A single structured log record produced by the Logger.
|
|
17
|
+
*
|
|
18
|
+
* **Immutability contract.** Once an entry is handed to the transports it is
|
|
19
|
+
* frozen (see {@link freezeEntry}): the entry itself and its `context`,
|
|
20
|
+
* `metadata` and `args` containers become read-only, and the entry is shared by
|
|
21
|
+
* reference (zero-copy) across every transport, formatter and plugin. Treat
|
|
22
|
+
* nested values as immutable too — they are intentionally NOT deep-frozen so we
|
|
23
|
+
* never pay a serialization/clone cost on the hot path.
|
|
24
|
+
*
|
|
25
|
+
* Across a process boundary (Electron IPC) the entry is serialised once into a
|
|
26
|
+
* transferable `ArrayBuffer` and moved (not copied) to the other process; the
|
|
27
|
+
* receiver deserialises a fresh, independent entry.
|
|
28
|
+
*/
|
|
29
|
+
export interface LogEntry {
|
|
30
|
+
/** Numeric severity, see {@link LOG_LEVELS}. */
|
|
31
|
+
level: LogLevelValue;
|
|
32
|
+
/** Human readable level name. */
|
|
33
|
+
levelName: LogLevelName;
|
|
34
|
+
/** Primary message text. */
|
|
35
|
+
message: string;
|
|
36
|
+
/** Extra positional arguments passed to the log call. */
|
|
37
|
+
args: unknown[];
|
|
38
|
+
/** Epoch milliseconds when the entry was created. */
|
|
39
|
+
timestamp: number;
|
|
40
|
+
/** Coarse ISO timestamp for display / serialization. */
|
|
41
|
+
time: string;
|
|
42
|
+
/** Scope / namespace, e.g. child logger name. */
|
|
43
|
+
scope?: string;
|
|
44
|
+
/** Process id when available (Electron main / Node). */
|
|
45
|
+
pid?: number;
|
|
46
|
+
/** Persistent contextual fields (see Context module). */
|
|
47
|
+
context: Record<string, unknown>;
|
|
48
|
+
/** One-off metadata attached to this entry only. */
|
|
49
|
+
metadata: Record<string, unknown>;
|
|
50
|
+
/** Error object when the entry was created from one. */
|
|
51
|
+
error?: Error;
|
|
52
|
+
}
|
|
53
|
+
export type LogFn = (message: unknown, ...args: unknown[]) => void;
|
|
54
|
+
export interface LoggerMethods {
|
|
55
|
+
trace: LogFn;
|
|
56
|
+
debug: LogFn;
|
|
57
|
+
info: LogFn;
|
|
58
|
+
warn: LogFn;
|
|
59
|
+
error: LogFn;
|
|
60
|
+
fatal: LogFn;
|
|
61
|
+
}
|
|
62
|
+
export type LogLevelInput = LogLevelName | LogLevelValue;
|
|
63
|
+
export declare function normalizeLevel(input: LogLevelInput): LogLevelValue;
|
|
64
|
+
/** Cross-process command sent over IPC to change log level. */
|
|
65
|
+
export interface LogLevelCommand {
|
|
66
|
+
__lograilCmd: true;
|
|
67
|
+
__lograilCmdType: 'setLevel';
|
|
68
|
+
level: LogLevelName | LogLevelValue;
|
|
69
|
+
}
|
|
70
|
+
/** Returns true when the value is a {@link LogLevelCommand}. */
|
|
71
|
+
export declare function isLogLevelCommand(value: unknown): value is LogLevelCommand;
|
|
72
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OA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AAM,aAAa,GAAG,YAAY,GAAG,aAAa,CAAC;AAEzD,wBAAgB,cAAc,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,CASlE;AAED,+DAA+D;AAC/D,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,IAAI,CAAC;IACnB,gBAAgB,EAAE,UAAU,CAAC;IAC7B,KAAK,EAAE,YAAY,GAAG,aAAa,CAAC;CACrC;AAED,gEAAgE;AAChE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAO1E"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shared type definitions for the logging library.
|
|
4
|
+
*
|
|
5
|
+
* These types form the stable contract used across Core, Pipeline,
|
|
6
|
+
* Transport, Runtime and Plugin modules.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.LOG_LEVEL_NAMES = exports.LOG_LEVELS = void 0;
|
|
10
|
+
exports.isLogLevelName = isLogLevelName;
|
|
11
|
+
exports.normalizeLevel = normalizeLevel;
|
|
12
|
+
exports.isLogLevelCommand = isLogLevelCommand;
|
|
13
|
+
/**
|
|
14
|
+
* Ordered by severity. Higher value means more severe.
|
|
15
|
+
*/
|
|
16
|
+
exports.LOG_LEVELS = {
|
|
17
|
+
trace: 10,
|
|
18
|
+
debug: 20,
|
|
19
|
+
info: 30,
|
|
20
|
+
warn: 40,
|
|
21
|
+
error: 50,
|
|
22
|
+
fatal: 60,
|
|
23
|
+
};
|
|
24
|
+
exports.LOG_LEVEL_NAMES = Object.keys(exports.LOG_LEVELS);
|
|
25
|
+
function isLogLevelName(value) {
|
|
26
|
+
return typeof value === 'string' && value in exports.LOG_LEVELS;
|
|
27
|
+
}
|
|
28
|
+
function normalizeLevel(input) {
|
|
29
|
+
if (typeof input === 'number') {
|
|
30
|
+
return input;
|
|
31
|
+
}
|
|
32
|
+
const value = exports.LOG_LEVELS[input];
|
|
33
|
+
if (value === undefined) {
|
|
34
|
+
throw new Error(`Unknown log level: ${String(input)}`);
|
|
35
|
+
}
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
/** Returns true when the value is a {@link LogLevelCommand}. */
|
|
39
|
+
function isLogLevelCommand(value) {
|
|
40
|
+
return (typeof value === 'object' &&
|
|
41
|
+
value !== null &&
|
|
42
|
+
value.__lograilCmd === true &&
|
|
43
|
+
value.__lograilCmdType === 'setLevel');
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAoBH,wCAEC;AAsDD,wCASC;AAUD,8CAOC;AAhGD;;GAEG;AACU,QAAA,UAAU,GAAwC;IAC7D,KAAK,EAAE,EAAE;IACT,KAAK,EAAE,EAAE;IACT,IAAI,EAAE,EAAE;IACR,IAAI,EAAE,EAAE;IACR,KAAK,EAAE,EAAE;IACT,KAAK,EAAE,EAAE;CACV,CAAC;AAEW,QAAA,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,kBAAU,CAAmB,CAAC;AAEzE,SAAgB,cAAc,CAAC,KAAc;IAC3C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,IAAI,kBAAU,CAAC;AAC1D,CAAC;AAsDD,SAAgB,cAAc,CAAC,KAAoB;IACjD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,KAAK,GAAG,kBAAU,CAAC,KAAK,CAAC,CAAC;IAChC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,sBAAsB,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AASD,gEAAgE;AAChE,SAAgB,iBAAiB,CAAC,KAAc;IAC9C,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACb,KAAiC,CAAC,YAAY,KAAK,IAAI;QACvD,KAAiC,CAAC,gBAAgB,KAAK,UAAU,CACnE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type AmbientContext = Record<string, unknown>;
|
|
2
|
+
/**
|
|
3
|
+
* Browser / non-Node stub. `AsyncLocalStorage` is unavailable here, so ambient
|
|
4
|
+
* context is a no-op — logs are unaffected and no context propagates. The real
|
|
5
|
+
* implementation (`async-context.ts`) is selected over this file in Node builds
|
|
6
|
+
* via the `browser` field in `package.json`.
|
|
7
|
+
*/
|
|
8
|
+
export declare const asyncContext: {
|
|
9
|
+
run<T>(fn: () => T, _context: AmbientContext): T;
|
|
10
|
+
runAsync<T>(fn: () => Promise<T>, _context: AmbientContext): Promise<T>;
|
|
11
|
+
get(): AmbientContext;
|
|
12
|
+
supported(): boolean;
|
|
13
|
+
};
|
|
14
|
+
/** Run `fn` with `context` active as the ambient logging context (no-op outside Node). */
|
|
15
|
+
export declare function runWithContext<T>(fn: () => T, _context: AmbientContext): T;
|
|
16
|
+
//# sourceMappingURL=async-context.browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-context.browser.d.ts","sourceRoot":"","sources":["../../../src/context/async-context.browser.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAErD;;;;;GAKG;AACH,eAAO,MAAM,YAAY;QACnB,CAAC,MAAM,MAAM,CAAC,YAAY,cAAc,GAAG,CAAC;aAGvC,CAAC,MAAM,MAAM,OAAO,CAAC,CAAC,CAAC,YAAY,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;WAGhE,cAAc;iBAGR,OAAO;CAGrB,CAAC;AAEF,0FAA0F;AAC1F,wBAAgB,cAAc,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,cAAc,GAAG,CAAC,CAE1E"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser / non-Node stub. `AsyncLocalStorage` is unavailable here, so ambient
|
|
3
|
+
* context is a no-op — logs are unaffected and no context propagates. The real
|
|
4
|
+
* implementation (`async-context.ts`) is selected over this file in Node builds
|
|
5
|
+
* via the `browser` field in `package.json`.
|
|
6
|
+
*/
|
|
7
|
+
export const asyncContext = {
|
|
8
|
+
run(fn, _context) {
|
|
9
|
+
return fn();
|
|
10
|
+
},
|
|
11
|
+
runAsync(fn, _context) {
|
|
12
|
+
return fn();
|
|
13
|
+
},
|
|
14
|
+
get() {
|
|
15
|
+
return {};
|
|
16
|
+
},
|
|
17
|
+
supported() {
|
|
18
|
+
return false;
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
/** Run `fn` with `context` active as the ambient logging context (no-op outside Node). */
|
|
22
|
+
export function runWithContext(fn, _context) {
|
|
23
|
+
return fn();
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=async-context.browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-context.browser.js","sourceRoot":"","sources":["../../../src/context/async-context.browser.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,GAAG,CAAI,EAAW,EAAE,QAAwB;QAC1C,OAAO,EAAE,EAAE,CAAC;IACd,CAAC;IACD,QAAQ,CAAI,EAAoB,EAAE,QAAwB;QACxD,OAAO,EAAE,EAAE,CAAC;IACd,CAAC;IACD,GAAG;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,SAAS;QACP,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAC;AAEF,0FAA0F;AAC1F,MAAM,UAAU,cAAc,CAAI,EAAW,EAAE,QAAwB;IACrE,OAAO,EAAE,EAAE,CAAC;AACd,CAAC"}
|