@vibesdotdev/logging 0.0.1
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/README.md +80 -0
- package/SPEC.md +65 -0
- package/dist/audit/audit.descriptor.d.ts +11 -0
- package/dist/audit/audit.descriptor.d.ts.map +1 -0
- package/dist/audit/audit.descriptor.js +40 -0
- package/dist/audit/audit.descriptor.js.map +1 -0
- package/dist/audit/audit.storage.schema.d.ts +79 -0
- package/dist/audit/audit.storage.schema.d.ts.map +1 -0
- package/dist/audit/audit.storage.schema.js +33 -0
- package/dist/audit/audit.storage.schema.js.map +1 -0
- package/dist/audit/index.d.ts +2 -0
- package/dist/audit/index.d.ts.map +1 -0
- package/dist/audit/index.js +2 -0
- package/dist/audit/index.js.map +1 -0
- package/dist/cli/logs.descriptor.d.ts +9 -0
- package/dist/cli/logs.descriptor.d.ts.map +1 -0
- package/dist/cli/logs.descriptor.js +16 -0
- package/dist/cli/logs.descriptor.js.map +1 -0
- package/dist/cli/logs.list.descriptor.d.ts +9 -0
- package/dist/cli/logs.list.descriptor.d.ts.map +1 -0
- package/dist/cli/logs.list.descriptor.js +23 -0
- package/dist/cli/logs.list.descriptor.js.map +1 -0
- package/dist/cli/logs.list.impl.d.ts +13 -0
- package/dist/cli/logs.list.impl.d.ts.map +1 -0
- package/dist/cli/logs.list.impl.js +81 -0
- package/dist/cli/logs.list.impl.js.map +1 -0
- package/dist/cli/logs.rotate.descriptor.d.ts +9 -0
- package/dist/cli/logs.rotate.descriptor.d.ts.map +1 -0
- package/dist/cli/logs.rotate.descriptor.js +34 -0
- package/dist/cli/logs.rotate.descriptor.js.map +1 -0
- package/dist/cli/logs.rotate.impl.d.ts +17 -0
- package/dist/cli/logs.rotate.impl.d.ts.map +1 -0
- package/dist/cli/logs.rotate.impl.js +48 -0
- package/dist/cli/logs.rotate.impl.js.map +1 -0
- package/dist/cli/logs.search.descriptor.d.ts +9 -0
- package/dist/cli/logs.search.descriptor.d.ts.map +1 -0
- package/dist/cli/logs.search.descriptor.js +55 -0
- package/dist/cli/logs.search.descriptor.js.map +1 -0
- package/dist/cli/logs.search.impl.d.ts +22 -0
- package/dist/cli/logs.search.impl.d.ts.map +1 -0
- package/dist/cli/logs.search.impl.js +145 -0
- package/dist/cli/logs.search.impl.js.map +1 -0
- package/dist/cli/logs.tail.descriptor.d.ts +9 -0
- package/dist/cli/logs.tail.descriptor.d.ts.map +1 -0
- package/dist/cli/logs.tail.descriptor.js +43 -0
- package/dist/cli/logs.tail.descriptor.js.map +1 -0
- package/dist/cli/logs.tail.impl.d.ts +19 -0
- package/dist/cli/logs.tail.impl.d.ts.map +1 -0
- package/dist/cli/logs.tail.impl.js +78 -0
- package/dist/cli/logs.tail.impl.js.map +1 -0
- package/dist/cli/logs.view.descriptor.d.ts +9 -0
- package/dist/cli/logs.view.descriptor.d.ts.map +1 -0
- package/dist/cli/logs.view.descriptor.js +51 -0
- package/dist/cli/logs.view.descriptor.js.map +1 -0
- package/dist/cli/logs.view.impl.d.ts +21 -0
- package/dist/cli/logs.view.impl.d.ts.map +1 -0
- package/dist/cli/logs.view.impl.js +85 -0
- package/dist/cli/logs.view.impl.js.map +1 -0
- package/dist/cli/types.d.ts +57 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +9 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/contexts/audit.d.ts +34 -0
- package/dist/contexts/audit.d.ts.map +1 -0
- package/dist/contexts/audit.js +13 -0
- package/dist/contexts/audit.js.map +1 -0
- package/dist/contexts/fallback-logger.d.ts +3 -0
- package/dist/contexts/fallback-logger.d.ts.map +1 -0
- package/dist/contexts/fallback-logger.js +67 -0
- package/dist/contexts/fallback-logger.js.map +1 -0
- package/dist/contexts/index.d.ts +8 -0
- package/dist/contexts/index.d.ts.map +1 -0
- package/dist/contexts/index.js +9 -0
- package/dist/contexts/index.js.map +1 -0
- package/dist/contexts/logger.d.ts +26 -0
- package/dist/contexts/logger.d.ts.map +1 -0
- package/dist/contexts/logger.js +88 -0
- package/dist/contexts/logger.js.map +1 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +10 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/logger.d.ts +3 -0
- package/dist/core/logger.d.ts.map +1 -0
- package/dist/core/logger.js +118 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/namespace.d.ts +69 -0
- package/dist/core/namespace.d.ts.map +1 -0
- package/dist/core/namespace.js +136 -0
- package/dist/core/namespace.js.map +1 -0
- package/dist/core/parsing.d.ts +3 -0
- package/dist/core/parsing.d.ts.map +1 -0
- package/dist/core/parsing.js +25 -0
- package/dist/core/parsing.js.map +1 -0
- package/dist/core/types.d.ts +69 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +7 -0
- package/dist/core/types.js.map +1 -0
- package/dist/docs/levels.docs.descriptor.d.ts +4 -0
- package/dist/docs/levels.docs.descriptor.d.ts.map +1 -0
- package/dist/docs/levels.docs.descriptor.js +342 -0
- package/dist/docs/levels.docs.descriptor.js.map +1 -0
- package/dist/docs/structured.docs.descriptor.d.ts +4 -0
- package/dist/docs/structured.docs.descriptor.d.ts.map +1 -0
- package/dist/docs/structured.docs.descriptor.js +442 -0
- package/dist/docs/structured.docs.descriptor.js.map +1 -0
- package/dist/docs/transports.docs.descriptor.d.ts +4 -0
- package/dist/docs/transports.docs.descriptor.d.ts.map +1 -0
- package/dist/docs/transports.docs.descriptor.js +426 -0
- package/dist/docs/transports.docs.descriptor.js.map +1 -0
- package/dist/formatters/index.d.ts +7 -0
- package/dist/formatters/index.d.ts.map +1 -0
- package/dist/formatters/index.js +8 -0
- package/dist/formatters/index.js.map +1 -0
- package/dist/formatters/json/json.formatters.descriptor.d.ts +9 -0
- package/dist/formatters/json/json.formatters.descriptor.d.ts.map +1 -0
- package/dist/formatters/json/json.formatters.descriptor.js +22 -0
- package/dist/formatters/json/json.formatters.descriptor.js.map +1 -0
- package/dist/formatters/json/json.impl.d.ts +22 -0
- package/dist/formatters/json/json.impl.d.ts.map +1 -0
- package/dist/formatters/json/json.impl.js +32 -0
- package/dist/formatters/json/json.impl.js.map +1 -0
- package/dist/formatters/json5/json5.descriptor.d.ts +9 -0
- package/dist/formatters/json5/json5.descriptor.d.ts.map +1 -0
- package/dist/formatters/json5/json5.descriptor.js +22 -0
- package/dist/formatters/json5/json5.descriptor.js.map +1 -0
- package/dist/formatters/json5/json5.impl.d.ts +23 -0
- package/dist/formatters/json5/json5.impl.d.ts.map +1 -0
- package/dist/formatters/json5/json5.impl.js +34 -0
- package/dist/formatters/json5/json5.impl.js.map +1 -0
- package/dist/formatters/jsonl/jsonl.descriptor.d.ts +10 -0
- package/dist/formatters/jsonl/jsonl.descriptor.d.ts.map +1 -0
- package/dist/formatters/jsonl/jsonl.descriptor.js +23 -0
- package/dist/formatters/jsonl/jsonl.descriptor.js.map +1 -0
- package/dist/formatters/jsonl/jsonl.impl.d.ts +21 -0
- package/dist/formatters/jsonl/jsonl.impl.d.ts.map +1 -0
- package/dist/formatters/jsonl/jsonl.impl.js +30 -0
- package/dist/formatters/jsonl/jsonl.impl.js.map +1 -0
- package/dist/formatters/pretty/pretty.descriptor.d.ts +9 -0
- package/dist/formatters/pretty/pretty.descriptor.d.ts.map +1 -0
- package/dist/formatters/pretty/pretty.descriptor.js +23 -0
- package/dist/formatters/pretty/pretty.descriptor.js.map +1 -0
- package/dist/formatters/pretty/pretty.impl.cli.d.ts +23 -0
- package/dist/formatters/pretty/pretty.impl.cli.d.ts.map +1 -0
- package/dist/formatters/pretty/pretty.impl.cli.js +81 -0
- package/dist/formatters/pretty/pretty.impl.cli.js.map +1 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +97 -0
- package/dist/index.js.map +1 -0
- package/dist/kinds/audit.d.ts +85 -0
- package/dist/kinds/audit.d.ts.map +1 -0
- package/dist/kinds/audit.js +71 -0
- package/dist/kinds/audit.js.map +1 -0
- package/dist/kinds/contexts.d.ts +21 -0
- package/dist/kinds/contexts.d.ts.map +1 -0
- package/dist/kinds/contexts.js +8 -0
- package/dist/kinds/contexts.js.map +1 -0
- package/dist/kinds/formatter.d.ts +42 -0
- package/dist/kinds/formatter.d.ts.map +1 -0
- package/dist/kinds/formatter.js +69 -0
- package/dist/kinds/formatter.js.map +1 -0
- package/dist/kinds/index.d.ts +13 -0
- package/dist/kinds/index.d.ts.map +1 -0
- package/dist/kinds/index.js +13 -0
- package/dist/kinds/index.js.map +1 -0
- package/dist/kinds/logger.contracts.d.ts +16 -0
- package/dist/kinds/logger.contracts.d.ts.map +1 -0
- package/dist/kinds/logger.contracts.js +9 -0
- package/dist/kinds/logger.contracts.js.map +1 -0
- package/dist/kinds/logger.d.ts +15 -0
- package/dist/kinds/logger.d.ts.map +1 -0
- package/dist/kinds/logger.impl.d.ts +40 -0
- package/dist/kinds/logger.impl.d.ts.map +1 -0
- package/dist/kinds/logger.impl.js +139 -0
- package/dist/kinds/logger.impl.js.map +1 -0
- package/dist/kinds/logger.js +28 -0
- package/dist/kinds/logger.js.map +1 -0
- package/dist/kinds/logger.utils.d.ts +15 -0
- package/dist/kinds/logger.utils.d.ts.map +1 -0
- package/dist/kinds/logger.utils.js +55 -0
- package/dist/kinds/logger.utils.js.map +1 -0
- package/dist/kinds/output.contracts.d.ts +50 -0
- package/dist/kinds/output.contracts.d.ts.map +1 -0
- package/dist/kinds/output.contracts.js +10 -0
- package/dist/kinds/output.contracts.js.map +1 -0
- package/dist/kinds/output.d.ts +20 -0
- package/dist/kinds/output.d.ts.map +1 -0
- package/dist/kinds/output.impl.d.ts +22 -0
- package/dist/kinds/output.impl.d.ts.map +1 -0
- package/dist/kinds/output.impl.js +84 -0
- package/dist/kinds/output.impl.js.map +1 -0
- package/dist/kinds/output.js +29 -0
- package/dist/kinds/output.js.map +1 -0
- package/dist/kinds/output.types.d.ts +92 -0
- package/dist/kinds/output.types.d.ts.map +1 -0
- package/dist/kinds/output.types.js +7 -0
- package/dist/kinds/output.types.js.map +1 -0
- package/dist/kinds/sink.d.ts +40 -0
- package/dist/kinds/sink.d.ts.map +1 -0
- package/dist/kinds/sink.js +61 -0
- package/dist/kinds/sink.js.map +1 -0
- package/dist/logger.context.descriptor.d.ts +21 -0
- package/dist/logger.context.descriptor.d.ts.map +1 -0
- package/dist/logger.context.descriptor.js +12 -0
- package/dist/logger.context.descriptor.js.map +1 -0
- package/dist/logging.cli.plugin.d.ts +20 -0
- package/dist/logging.cli.plugin.d.ts.map +1 -0
- package/dist/logging.cli.plugin.js +39 -0
- package/dist/logging.cli.plugin.js.map +1 -0
- package/dist/logging.plugin.d.ts +16 -0
- package/dist/logging.plugin.d.ts.map +1 -0
- package/dist/logging.plugin.js +83 -0
- package/dist/logging.plugin.js.map +1 -0
- package/dist/outputs/index.d.ts +7 -0
- package/dist/outputs/index.d.ts.map +1 -0
- package/dist/outputs/index.js +8 -0
- package/dist/outputs/index.js.map +1 -0
- package/dist/outputs/remote/remote.descriptor.d.ts +10 -0
- package/dist/outputs/remote/remote.descriptor.d.ts.map +1 -0
- package/dist/outputs/remote/remote.descriptor.js +24 -0
- package/dist/outputs/remote/remote.descriptor.js.map +1 -0
- package/dist/outputs/remote/remote.impl.d.ts +50 -0
- package/dist/outputs/remote/remote.impl.d.ts.map +1 -0
- package/dist/outputs/remote/remote.impl.js +178 -0
- package/dist/outputs/remote/remote.impl.js.map +1 -0
- package/dist/outputs.context.descriptor.d.ts +19 -0
- package/dist/outputs.context.descriptor.d.ts.map +1 -0
- package/dist/outputs.context.descriptor.js +9 -0
- package/dist/outputs.context.descriptor.js.map +1 -0
- package/dist/outputs.context.impl.d.ts +9 -0
- package/dist/outputs.context.impl.d.ts.map +1 -0
- package/dist/outputs.context.impl.js +18 -0
- package/dist/outputs.context.impl.js.map +1 -0
- package/dist/paths.d.ts +8 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +10 -0
- package/dist/paths.js.map +1 -0
- package/dist/schemas/audit.d.ts +133 -0
- package/dist/schemas/audit.d.ts.map +1 -0
- package/dist/schemas/audit.js +80 -0
- package/dist/schemas/audit.js.map +1 -0
- package/dist/schemas/entry.d.ts +74 -0
- package/dist/schemas/entry.d.ts.map +1 -0
- package/dist/schemas/entry.js +62 -0
- package/dist/schemas/entry.js.map +1 -0
- package/dist/schemas/formatter.d.ts +46 -0
- package/dist/schemas/formatter.d.ts.map +1 -0
- package/dist/schemas/formatter.js +31 -0
- package/dist/schemas/formatter.js.map +1 -0
- package/dist/schemas/index.d.ts +12 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +18 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/logger.d.ts +48 -0
- package/dist/schemas/logger.d.ts.map +1 -0
- package/dist/schemas/logger.js +27 -0
- package/dist/schemas/logger.js.map +1 -0
- package/dist/schemas/output.d.ts +68 -0
- package/dist/schemas/output.d.ts.map +1 -0
- package/dist/schemas/output.js +48 -0
- package/dist/schemas/output.js.map +1 -0
- package/dist/schemas/sink.d.ts +52 -0
- package/dist/schemas/sink.d.ts.map +1 -0
- package/dist/schemas/sink.js +30 -0
- package/dist/schemas/sink.js.map +1 -0
- package/dist/sinks/buffer/buffer.descriptor.d.ts +4 -0
- package/dist/sinks/buffer/buffer.descriptor.d.ts.map +1 -0
- package/dist/sinks/buffer/buffer.descriptor.js +11 -0
- package/dist/sinks/buffer/buffer.descriptor.js.map +1 -0
- package/dist/sinks/buffer/buffer.impl.cli.d.ts +21 -0
- package/dist/sinks/buffer/buffer.impl.cli.d.ts.map +1 -0
- package/dist/sinks/buffer/buffer.impl.cli.js +34 -0
- package/dist/sinks/buffer/buffer.impl.cli.js.map +1 -0
- package/dist/sinks/console/console.descriptor.d.ts +10 -0
- package/dist/sinks/console/console.descriptor.d.ts.map +1 -0
- package/dist/sinks/console/console.descriptor.js +17 -0
- package/dist/sinks/console/console.descriptor.js.map +1 -0
- package/dist/sinks/console/console.impl.browser.d.ts +21 -0
- package/dist/sinks/console/console.impl.browser.d.ts.map +1 -0
- package/dist/sinks/console/console.impl.browser.js +57 -0
- package/dist/sinks/console/console.impl.browser.js.map +1 -0
- package/dist/sinks/console/console.impl.cli.d.ts +21 -0
- package/dist/sinks/console/console.impl.cli.d.ts.map +1 -0
- package/dist/sinks/console/console.impl.cli.js +57 -0
- package/dist/sinks/console/console.impl.cli.js.map +1 -0
- package/dist/sinks/index.d.ts +8 -0
- package/dist/sinks/index.d.ts.map +1 -0
- package/dist/sinks/index.js +8 -0
- package/dist/sinks/index.js.map +1 -0
- package/dist/sinks/memory/memory.descriptor.d.ts +10 -0
- package/dist/sinks/memory/memory.descriptor.d.ts.map +1 -0
- package/dist/sinks/memory/memory.descriptor.js +17 -0
- package/dist/sinks/memory/memory.descriptor.js.map +1 -0
- package/dist/sinks/memory/memory.impl.d.ts +50 -0
- package/dist/sinks/memory/memory.impl.d.ts.map +1 -0
- package/dist/sinks/memory/memory.impl.js +88 -0
- package/dist/sinks/memory/memory.impl.js.map +1 -0
- package/dist/sinks/stdout/stdout.descriptor.d.ts +4 -0
- package/dist/sinks/stdout/stdout.descriptor.d.ts.map +1 -0
- package/dist/sinks/stdout/stdout.descriptor.js +11 -0
- package/dist/sinks/stdout/stdout.descriptor.js.map +1 -0
- package/dist/sinks/stdout/stdout.impl.cli.d.ts +10 -0
- package/dist/sinks/stdout/stdout.impl.cli.d.ts.map +1 -0
- package/dist/sinks/stdout/stdout.impl.cli.js +21 -0
- package/dist/sinks/stdout/stdout.impl.cli.js.map +1 -0
- package/dist/sinks.context.descriptor.d.ts +19 -0
- package/dist/sinks.context.descriptor.d.ts.map +1 -0
- package/dist/sinks.context.descriptor.js +9 -0
- package/dist/sinks.context.descriptor.js.map +1 -0
- package/dist/sinks.context.impl.d.ts +9 -0
- package/dist/sinks.context.impl.d.ts.map +1 -0
- package/dist/sinks.context.impl.js +18 -0
- package/dist/sinks.context.impl.js.map +1 -0
- package/package.json +331 -0
- package/src/audit/audit.descriptor.ts +45 -0
- package/src/audit/audit.storage.schema.ts +57 -0
- package/src/audit/index.ts +8 -0
- package/src/cli/logs.descriptor.ts +19 -0
- package/src/cli/logs.list.descriptor.ts +28 -0
- package/src/cli/logs.list.impl.ts +93 -0
- package/src/cli/logs.rotate.descriptor.ts +40 -0
- package/src/cli/logs.rotate.impl.ts +61 -0
- package/src/cli/logs.search.descriptor.ts +61 -0
- package/src/cli/logs.search.impl.ts +173 -0
- package/src/cli/logs.tail.descriptor.ts +49 -0
- package/src/cli/logs.tail.impl.ts +105 -0
- package/src/cli/logs.view.descriptor.ts +57 -0
- package/src/cli/logs.view.impl.ts +108 -0
- package/src/cli/types.ts +59 -0
- package/src/contexts/audit.ts +36 -0
- package/src/contexts/fallback-logger.ts +80 -0
- package/src/contexts/index.ts +23 -0
- package/src/contexts/logger.ts +119 -0
- package/src/core/index.ts +32 -0
- package/src/core/logger.ts +150 -0
- package/src/core/namespace.ts +195 -0
- package/src/core/parsing.ts +21 -0
- package/src/core/types.ts +82 -0
- package/src/docs/levels.docs.descriptor.ts +344 -0
- package/src/docs/structured.docs.descriptor.ts +444 -0
- package/src/docs/transports.docs.descriptor.ts +428 -0
- package/src/formatters/index.ts +6 -0
- package/src/formatters/json/json.formatters.descriptor.ts +25 -0
- package/src/formatters/json/json.impl.ts +41 -0
- package/src/formatters/json5/json5.descriptor.ts +25 -0
- package/src/formatters/json5/json5.impl.ts +43 -0
- package/src/formatters/jsonl/jsonl.descriptor.ts +26 -0
- package/src/formatters/jsonl/jsonl.impl.ts +39 -0
- package/src/formatters/pretty/pretty.descriptor.ts +26 -0
- package/src/formatters/pretty/pretty.impl.cli.ts +101 -0
- package/src/index.ts +190 -0
- package/src/kinds/audit.ts +169 -0
- package/src/kinds/contexts.ts +22 -0
- package/src/kinds/formatter.ts +117 -0
- package/src/kinds/index.ts +25 -0
- package/src/kinds/logger.contracts.ts +17 -0
- package/src/kinds/logger.impl.ts +206 -0
- package/src/kinds/logger.ts +46 -0
- package/src/kinds/logger.utils.ts +91 -0
- package/src/kinds/output.contracts.ts +54 -0
- package/src/kinds/output.impl.ts +118 -0
- package/src/kinds/output.ts +59 -0
- package/src/kinds/output.types.ts +105 -0
- package/src/kinds/sink.ts +100 -0
- package/src/logger.context.descriptor.ts +13 -0
- package/src/logging.cli.plugin.ts +43 -0
- package/src/logging.plugin.ts +93 -0
- package/src/outputs/index.ts +6 -0
- package/src/outputs/remote/remote.descriptor.ts +27 -0
- package/src/outputs/remote/remote.impl.ts +218 -0
- package/src/outputs.context.descriptor.ts +10 -0
- package/src/outputs.context.impl.ts +30 -0
- package/src/paths.ts +10 -0
- package/src/schemas/audit.ts +98 -0
- package/src/schemas/entry.ts +88 -0
- package/src/schemas/formatter.ts +37 -0
- package/src/schemas/index.ts +80 -0
- package/src/schemas/logger.ts +38 -0
- package/src/schemas/output.ts +62 -0
- package/src/schemas/sink.ts +39 -0
- package/src/sinks/buffer/buffer.descriptor.ts +13 -0
- package/src/sinks/buffer/buffer.impl.cli.ts +49 -0
- package/src/sinks/console/console.descriptor.ts +20 -0
- package/src/sinks/console/console.impl.browser.ts +69 -0
- package/src/sinks/console/console.impl.cli.ts +71 -0
- package/src/sinks/index.ts +8 -0
- package/src/sinks/memory/memory.descriptor.ts +20 -0
- package/src/sinks/memory/memory.impl.ts +119 -0
- package/src/sinks/stdout/stdout.descriptor.ts +13 -0
- package/src/sinks/stdout/stdout.impl.cli.ts +27 -0
- package/src/sinks.context.descriptor.ts +10 -0
- package/src/sinks.context.impl.ts +30 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import type { LoggerDescriptor } from '../schemas/logger.ts';
|
|
2
|
+
import type {
|
|
3
|
+
LogLevel,
|
|
4
|
+
LogContext,
|
|
5
|
+
RuntimeLogEntry,
|
|
6
|
+
LoggerChildOptions,
|
|
7
|
+
RequestLogContext,
|
|
8
|
+
JobLogContext,
|
|
9
|
+
PerformanceTrackerParams,
|
|
10
|
+
PerformanceTracker
|
|
11
|
+
} from '../schemas/entry.ts';
|
|
12
|
+
export type { PerformanceTracker } from '../schemas/entry.ts';
|
|
13
|
+
import type { SinkImplementation } from './sink.ts';
|
|
14
|
+
import type { OutputImplementation } from './output.ts';
|
|
15
|
+
import type { LoggerContext } from './contexts.ts';
|
|
16
|
+
import { shouldLog, getNamespaceSettings, type NamespaceSettings } from '../core/namespace.ts';
|
|
17
|
+
import {
|
|
18
|
+
resolveSinkContext,
|
|
19
|
+
resolveOutputContext,
|
|
20
|
+
createDefaultConsoleSink,
|
|
21
|
+
deriveChildConfig,
|
|
22
|
+
resolveSinks,
|
|
23
|
+
resolveOutputs
|
|
24
|
+
} from './logger.utils';
|
|
25
|
+
import type { RuntimeDescriptor } from '@vibesdotdev/runtime/schemas/kind';
|
|
26
|
+
import type { KindContext } from '@vibesdotdev/runtime/schemas/kind';
|
|
27
|
+
|
|
28
|
+
export type { LoggerContext } from './contexts.ts';
|
|
29
|
+
|
|
30
|
+
const defaultSink = createDefaultConsoleSink();
|
|
31
|
+
|
|
32
|
+
export interface LoggerImplementation {
|
|
33
|
+
readonly namespace: string;
|
|
34
|
+
readonly fullNamespace: string;
|
|
35
|
+
debug(message: string, context?: unknown): void;
|
|
36
|
+
info(message: string, context?: unknown): void;
|
|
37
|
+
warn(message: string, context?: unknown): void;
|
|
38
|
+
error(message: string, context?: unknown): void;
|
|
39
|
+
child(options: LoggerChildOptions): LoggerImplementation;
|
|
40
|
+
withContext(context: LogContext): LoggerImplementation;
|
|
41
|
+
withRequestContext(context: RequestLogContext): LoggerImplementation;
|
|
42
|
+
withJobContext(context: JobLogContext): LoggerImplementation;
|
|
43
|
+
performanceTracker(params: PerformanceTrackerParams): PerformanceTracker;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function normalizeLogContext(context: unknown): LogContext {
|
|
47
|
+
if (context === undefined || context === null) {
|
|
48
|
+
return {};
|
|
49
|
+
}
|
|
50
|
+
if (context instanceof Error) {
|
|
51
|
+
return {
|
|
52
|
+
errorName: context.name,
|
|
53
|
+
errorMessage: context.message,
|
|
54
|
+
stack: context.stack
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
if (typeof context === 'object' && !Array.isArray(context)) {
|
|
58
|
+
return context as LogContext;
|
|
59
|
+
}
|
|
60
|
+
return { value: context };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export default class DefaultLoggerImplementation implements LoggerImplementation {
|
|
64
|
+
readonly namespace: string;
|
|
65
|
+
readonly fullNamespace: string;
|
|
66
|
+
private readonly descriptor: LoggerDescriptor;
|
|
67
|
+
private readonly sinks: SinkImplementation[];
|
|
68
|
+
private readonly outputs: OutputImplementation[];
|
|
69
|
+
private readonly staticMetadata: LogContext;
|
|
70
|
+
|
|
71
|
+
constructor(
|
|
72
|
+
descriptor: RuntimeDescriptor,
|
|
73
|
+
context: KindContext,
|
|
74
|
+
fullNamespace?: string,
|
|
75
|
+
additionalMetadata?: LogContext
|
|
76
|
+
) {
|
|
77
|
+
this.descriptor = descriptor as LoggerDescriptor;
|
|
78
|
+
this.namespace = (descriptor as LoggerDescriptor).namespace;
|
|
79
|
+
this.fullNamespace = fullNamespace ?? (descriptor as LoggerDescriptor).namespace;
|
|
80
|
+
const typedCtx = context as LoggerContext;
|
|
81
|
+
this.sinks = resolveSinks(descriptor as LoggerDescriptor, resolveSinkContext(typedCtx), defaultSink);
|
|
82
|
+
this.outputs = resolveOutputs(descriptor as LoggerDescriptor, resolveOutputContext(typedCtx));
|
|
83
|
+
this.staticMetadata = {
|
|
84
|
+
runtime: (descriptor as LoggerDescriptor).runtime,
|
|
85
|
+
...(descriptor as LoggerDescriptor).metadata,
|
|
86
|
+
...additionalMetadata
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
private getLevelSettings(): NamespaceSettings {
|
|
91
|
+
const base = getNamespaceSettings();
|
|
92
|
+
if (this.descriptor.level && base.defaultLevel !== this.descriptor.level) {
|
|
93
|
+
return { ...base, defaultLevel: this.descriptor.level };
|
|
94
|
+
}
|
|
95
|
+
return base;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
private emit(level: LogLevel, message: string, context?: unknown): void {
|
|
99
|
+
const settings = this.getLevelSettings();
|
|
100
|
+
if (!shouldLog({ namespace: this.fullNamespace, level, settings })) return;
|
|
101
|
+
|
|
102
|
+
const entry: RuntimeLogEntry = {
|
|
103
|
+
timestamp: new Date().toISOString(),
|
|
104
|
+
level,
|
|
105
|
+
namespace: this.fullNamespace,
|
|
106
|
+
message,
|
|
107
|
+
context: { ...this.staticMetadata, ...normalizeLogContext(context) }
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
for (const sink of this.sinks) {
|
|
111
|
+
try {
|
|
112
|
+
sink.emit(entry);
|
|
113
|
+
} catch (e) {
|
|
114
|
+
defaultSink.emit(entry);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
for (const output of this.outputs) {
|
|
119
|
+
try {
|
|
120
|
+
output.write(entry).catch(() => {});
|
|
121
|
+
} catch {
|
|
122
|
+
/* output sync error */
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
debug(message: string, context?: unknown): void { this.emit('debug', message, context); }
|
|
128
|
+
info(message: string, context?: unknown): void { this.emit('info', message, context); }
|
|
129
|
+
warn(message: string, context?: unknown): void { this.emit('warn', message, context); }
|
|
130
|
+
error(message: string, context?: unknown): void { this.emit('error', message, context); }
|
|
131
|
+
|
|
132
|
+
private createContextualLogger(merged: LogContext): LoggerImplementation {
|
|
133
|
+
return new DefaultLoggerImplementation(
|
|
134
|
+
this.descriptor,
|
|
135
|
+
{ runtime: undefined, sinks: this.sinks, outputs: this.outputs },
|
|
136
|
+
this.fullNamespace,
|
|
137
|
+
merged
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
child(options: LoggerChildOptions): LoggerImplementation {
|
|
142
|
+
const { nextNamespace, childMetadata } = deriveChildConfig(this.fullNamespace, options);
|
|
143
|
+
return new DefaultLoggerImplementation(
|
|
144
|
+
this.descriptor,
|
|
145
|
+
{ runtime: undefined, sinks: this.sinks, outputs: this.outputs },
|
|
146
|
+
nextNamespace,
|
|
147
|
+
{ ...this.staticMetadata, ...childMetadata }
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
withContext(context: LogContext): LoggerImplementation {
|
|
152
|
+
return this.createContextualLogger({ ...this.staticMetadata, ...context });
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
withRequestContext(context: RequestLogContext): LoggerImplementation {
|
|
156
|
+
const s = this.staticMetadata;
|
|
157
|
+
return this.createContextualLogger({
|
|
158
|
+
...s,
|
|
159
|
+
requestId: context.requestId ?? s.requestId,
|
|
160
|
+
correlationId: context.correlationId ?? s.correlationId,
|
|
161
|
+
sessionId: context.sessionId ?? s.sessionId,
|
|
162
|
+
userId: context.userId ?? s.userId,
|
|
163
|
+
userAgent: context.userAgent ?? s.userAgent,
|
|
164
|
+
ip: context.ip ?? s.ip,
|
|
165
|
+
route: context.route ?? s.route,
|
|
166
|
+
method: context.method ?? s.method
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
withJobContext(context: JobLogContext): LoggerImplementation {
|
|
171
|
+
const s = this.staticMetadata;
|
|
172
|
+
return this.createContextualLogger({
|
|
173
|
+
...s,
|
|
174
|
+
jobId: context.jobId ?? s.jobId,
|
|
175
|
+
queueId: context.queueId ?? s.queueId,
|
|
176
|
+
queueName: context.queueName ?? s.queueName,
|
|
177
|
+
toolId: context.toolId ?? s.toolId,
|
|
178
|
+
parentJobId: context.parentJobId ?? s.parentJobId,
|
|
179
|
+
attempt: context.attempt ?? s.attempt,
|
|
180
|
+
maxAttempts: context.maxAttempts ?? s.maxAttempts
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
performanceTracker(params: PerformanceTrackerParams): PerformanceTracker {
|
|
185
|
+
let startTime = 0;
|
|
186
|
+
const tracker = this.withContext({ operation: params.operation, ...params.metadata });
|
|
187
|
+
return {
|
|
188
|
+
start() {
|
|
189
|
+
startTime = Date.now();
|
|
190
|
+
tracker.debug(`operation.${params.operation}.start`);
|
|
191
|
+
},
|
|
192
|
+
end(successContext?: LogContext) {
|
|
193
|
+
const duration = Date.now() - startTime;
|
|
194
|
+
tracker.info(`operation.${params.operation}.success`, { duration, ...successContext });
|
|
195
|
+
},
|
|
196
|
+
fail(error: unknown, errorContext?: LogContext) {
|
|
197
|
+
const duration = Date.now() - startTime;
|
|
198
|
+
tracker.error(`operation.${params.operation}.failure`, {
|
|
199
|
+
duration,
|
|
200
|
+
error,
|
|
201
|
+
...errorContext
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { RuntimeKindDescriptor, KindContext, RuntimeDescriptor } from '@vibesdotdev/runtime/schemas/kind';
|
|
2
|
+
import type { RuntimeScope } from '@vibesdotdev/runtime/schemas/scope';
|
|
3
|
+
import { LoggerDescriptorSchema, type LoggerDescriptor } from '../schemas/logger.ts';
|
|
4
|
+
import DefaultLoggerImplementation, { type LoggerImplementation } from './logger.impl';
|
|
5
|
+
import type { LoggerContext } from './contexts.ts';
|
|
6
|
+
|
|
7
|
+
export type { LoggerImplementation, LoggerContext };
|
|
8
|
+
|
|
9
|
+
function resolveLogger(
|
|
10
|
+
candidates: RuntimeDescriptor[],
|
|
11
|
+
scope: RuntimeScope,
|
|
12
|
+
_context: KindContext
|
|
13
|
+
): LoggerDescriptor | undefined {
|
|
14
|
+
const typed = candidates as LoggerDescriptor[];
|
|
15
|
+
if (typed.length === 0) return undefined;
|
|
16
|
+
if (typed.length === 1) return typed[0];
|
|
17
|
+
|
|
18
|
+
const purposeToRuntime: Record<string, string> = {
|
|
19
|
+
cli: 'cli',
|
|
20
|
+
worker: 'worker',
|
|
21
|
+
mcp: 'mcp',
|
|
22
|
+
agent: 'server'
|
|
23
|
+
};
|
|
24
|
+
const runtime = purposeToRuntime[scope.purpose ?? ''] ?? 'server';
|
|
25
|
+
const matching = typed.filter((d) => d.runtime === runtime);
|
|
26
|
+
if (matching.length > 0) return matching[0];
|
|
27
|
+
return typed[0];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const loggerKind: RuntimeKindDescriptor<
|
|
31
|
+
LoggerDescriptor,
|
|
32
|
+
LoggerImplementation,
|
|
33
|
+
LoggerContext
|
|
34
|
+
> = {
|
|
35
|
+
id: 'logging/logger',
|
|
36
|
+
descriptorSchema: LoggerDescriptorSchema,
|
|
37
|
+
defaultImplementation: DefaultLoggerImplementation,
|
|
38
|
+
resolve: resolveLogger,
|
|
39
|
+
contexts: ['logging/sinks', 'logging/outputs']
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
declare module '@vibesdotdev/runtime/schemas/kind-types' {
|
|
43
|
+
interface KindTypeMap {
|
|
44
|
+
'logging/logger': { descriptor: LoggerDescriptor; impl: LoggerImplementation };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { LoggerDescriptor } from '../schemas/logger.ts';
|
|
2
|
+
import type { LogContext, LoggerChildOptions } from '../schemas/entry.ts';
|
|
3
|
+
import type { SinkImplementation } from './sink.ts';
|
|
4
|
+
import type { OutputImplementation } from './output.ts';
|
|
5
|
+
import type { LoggerContext } from './contexts.ts';
|
|
6
|
+
|
|
7
|
+
export function resolveSinkContext(
|
|
8
|
+
context: LoggerContext
|
|
9
|
+
): Map<string, SinkImplementation> | SinkImplementation[] | undefined {
|
|
10
|
+
const runtimeKeyed = (
|
|
11
|
+
context as LoggerContext & {
|
|
12
|
+
'logging/sinks'?: Map<string, SinkImplementation> | SinkImplementation[];
|
|
13
|
+
}
|
|
14
|
+
)['logging/sinks'];
|
|
15
|
+
return context.sinks ?? runtimeKeyed;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function resolveOutputContext(
|
|
19
|
+
context: LoggerContext
|
|
20
|
+
): Map<string, OutputImplementation> | OutputImplementation[] | undefined {
|
|
21
|
+
const runtimeKeyed = (
|
|
22
|
+
context as LoggerContext & {
|
|
23
|
+
'logging/outputs'?: Map<string, OutputImplementation> | OutputImplementation[];
|
|
24
|
+
}
|
|
25
|
+
)['logging/outputs'];
|
|
26
|
+
return context.outputs ?? runtimeKeyed;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function createDefaultConsoleSink(): SinkImplementation {
|
|
30
|
+
return {
|
|
31
|
+
emit(entry: { level: string; namespace: string; message: string; context: LogContext }): void {
|
|
32
|
+
const payload = JSON.stringify(entry.context);
|
|
33
|
+
const line = `[${entry.level.toUpperCase()}] [${entry.namespace}] ${entry.message} ${payload}`;
|
|
34
|
+
console.error(line);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function deriveChildConfig(
|
|
40
|
+
parentNamespace: string,
|
|
41
|
+
options: LoggerChildOptions
|
|
42
|
+
): { nextNamespace: string; childMetadata: LogContext } {
|
|
43
|
+
if (typeof options === 'string') {
|
|
44
|
+
return { nextNamespace: `${parentNamespace}:${options}`, childMetadata: {} };
|
|
45
|
+
}
|
|
46
|
+
const namespaceSuffix =
|
|
47
|
+
typeof options.namespace === 'string'
|
|
48
|
+
? options.namespace
|
|
49
|
+
: typeof options.context === 'string'
|
|
50
|
+
? options.context
|
|
51
|
+
: undefined;
|
|
52
|
+
return {
|
|
53
|
+
nextNamespace: namespaceSuffix ? `${parentNamespace}:${namespaceSuffix}` : parentNamespace,
|
|
54
|
+
childMetadata: { ...options }
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function resolveSinks(
|
|
59
|
+
descriptor: LoggerDescriptor,
|
|
60
|
+
resolvedSinkContext: Map<string, SinkImplementation> | SinkImplementation[] | undefined,
|
|
61
|
+
fallback: SinkImplementation
|
|
62
|
+
): SinkImplementation[] {
|
|
63
|
+
if (resolvedSinkContext instanceof Map) {
|
|
64
|
+
const resolved =
|
|
65
|
+
descriptor.sinks
|
|
66
|
+
?.map((id) => resolvedSinkContext.get(id))
|
|
67
|
+
.filter((s): s is SinkImplementation => s !== undefined) ?? [];
|
|
68
|
+
return resolved.length > 0 ? resolved : [fallback];
|
|
69
|
+
}
|
|
70
|
+
if (Array.isArray(resolvedSinkContext) && resolvedSinkContext.length > 0) {
|
|
71
|
+
return resolvedSinkContext;
|
|
72
|
+
}
|
|
73
|
+
return [fallback];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function resolveOutputs(
|
|
77
|
+
descriptor: LoggerDescriptor,
|
|
78
|
+
resolvedOutputContext: Map<string, OutputImplementation> | OutputImplementation[] | undefined
|
|
79
|
+
): OutputImplementation[] {
|
|
80
|
+
if (resolvedOutputContext instanceof Map) {
|
|
81
|
+
return (
|
|
82
|
+
descriptor.outputs
|
|
83
|
+
?.map((id) => resolvedOutputContext.get(id))
|
|
84
|
+
.filter((o): o is OutputImplementation => o !== undefined) ?? []
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
if (Array.isArray(resolvedOutputContext) && resolvedOutputContext.length > 0) {
|
|
88
|
+
return resolvedOutputContext;
|
|
89
|
+
}
|
|
90
|
+
return [];
|
|
91
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output kind contract types.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from `./output.ts` so the default implementation
|
|
5
|
+
* (`./output.impl.ts`) can implement these contracts without forming a
|
|
6
|
+
* cycle (output.ts itself imports the default implementation to wire it
|
|
7
|
+
* into the kind descriptor).
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { KindContext } from '@vibesdotdev/runtime/schemas/kind';
|
|
11
|
+
import type { RuntimeLogEntry } from '../schemas/entry.ts';
|
|
12
|
+
import type { FormatterImplementation } from './formatter.ts';
|
|
13
|
+
|
|
14
|
+
export interface OutputReadOptions {
|
|
15
|
+
lines?: number;
|
|
16
|
+
offset?: number;
|
|
17
|
+
filter?: string | RegExp;
|
|
18
|
+
ignoreCase?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface OutputTailOptions {
|
|
22
|
+
lines?: number;
|
|
23
|
+
filter?: string | RegExp;
|
|
24
|
+
ignoreCase?: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface TailHandle {
|
|
28
|
+
close(): void;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface OutputStats {
|
|
32
|
+
size: number;
|
|
33
|
+
lines?: number;
|
|
34
|
+
modifiedAt?: Date;
|
|
35
|
+
exists: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface OutputImplementation {
|
|
39
|
+
write(entry: RuntimeLogEntry): Promise<void>;
|
|
40
|
+
writeBatch?(entries: RuntimeLogEntry[]): Promise<void>;
|
|
41
|
+
writeLine?(line: string): Promise<void>;
|
|
42
|
+
flush(): Promise<void>;
|
|
43
|
+
close(): Promise<void>;
|
|
44
|
+
rotate?(): Promise<{ archived: string }>;
|
|
45
|
+
read(options?: OutputReadOptions): Promise<string[]>;
|
|
46
|
+
tail(callback: (line: string) => void, options?: OutputTailOptions): TailHandle;
|
|
47
|
+
stats(): Promise<OutputStats>;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface OutputContext extends KindContext {
|
|
51
|
+
readonly runtime: unknown;
|
|
52
|
+
readonly formatter?: FormatterImplementation;
|
|
53
|
+
readonly workspacePath?: string;
|
|
54
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
OutputReadOptions,
|
|
3
|
+
OutputTailOptions,
|
|
4
|
+
TailHandle,
|
|
5
|
+
OutputStats,
|
|
6
|
+
OutputImplementation,
|
|
7
|
+
OutputContext
|
|
8
|
+
} from './output.types';
|
|
9
|
+
import type { OutputDescriptor } from '../schemas/output.ts';
|
|
10
|
+
import type { RuntimeLogEntry } from '../schemas/entry.ts';
|
|
11
|
+
import type { RuntimeDescriptor } from '@vibesdotdev/runtime/schemas/kind';
|
|
12
|
+
import type { KindContext } from '@vibesdotdev/runtime/schemas/kind';
|
|
13
|
+
|
|
14
|
+
export class DefaultOutputImplementation implements OutputImplementation {
|
|
15
|
+
readonly id: string;
|
|
16
|
+
private readonly descriptor: OutputDescriptor;
|
|
17
|
+
private readonly context: OutputContext;
|
|
18
|
+
private delegate: OutputImplementation | null = null;
|
|
19
|
+
private delegatePromise: Promise<OutputImplementation> | null = null;
|
|
20
|
+
private pendingTailCloses: Array<() => void> = [];
|
|
21
|
+
|
|
22
|
+
constructor(
|
|
23
|
+
descriptor: RuntimeDescriptor,
|
|
24
|
+
context: KindContext
|
|
25
|
+
) {
|
|
26
|
+
this.id = descriptor.id;
|
|
27
|
+
this.descriptor = descriptor as OutputDescriptor;
|
|
28
|
+
this.context = context as OutputContext;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
private async resolveDelegate(): Promise<OutputImplementation> {
|
|
32
|
+
if (this.delegate) return this.delegate;
|
|
33
|
+
|
|
34
|
+
const storage = this.descriptor.storage ?? 'file';
|
|
35
|
+
const runtime = this.context.runtime as {
|
|
36
|
+
query(kind: string): {
|
|
37
|
+
withId(id: string): { resolve<T>(): Promise<T> };
|
|
38
|
+
};
|
|
39
|
+
hasKind(kind: string): boolean;
|
|
40
|
+
} | null;
|
|
41
|
+
|
|
42
|
+
if (runtime && runtime.hasKind('logging/output')) {
|
|
43
|
+
try {
|
|
44
|
+
const storageImpl = await runtime
|
|
45
|
+
.query('logging/output')
|
|
46
|
+
.withId(storage)
|
|
47
|
+
.resolve<OutputImplementation>();
|
|
48
|
+
|
|
49
|
+
const ImplClass = storageImpl.constructor as new (
|
|
50
|
+
descriptor: OutputDescriptor,
|
|
51
|
+
context: OutputContext
|
|
52
|
+
) => OutputImplementation;
|
|
53
|
+
this.delegate = new ImplClass(this.descriptor, this.context);
|
|
54
|
+
return this.delegate;
|
|
55
|
+
} catch {
|
|
56
|
+
// Fall through to error
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
throw new Error(
|
|
61
|
+
`No output implementation available for '${this.id}' (storage: ${storage}). ` +
|
|
62
|
+
`Ensure a '${storage}' output descriptor and implementation are registered.`
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
private getDelegatePromise(): Promise<OutputImplementation> {
|
|
67
|
+
if (this.delegate) return Promise.resolve(this.delegate);
|
|
68
|
+
if (!this.delegatePromise) {
|
|
69
|
+
this.delegatePromise = this.resolveDelegate().finally(() => {
|
|
70
|
+
this.delegatePromise = null;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return this.delegatePromise;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async write(entry: RuntimeLogEntry): Promise<void> {
|
|
77
|
+
return (await this.getDelegatePromise()).write(entry);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async flush(): Promise<void> {
|
|
81
|
+
return (await this.getDelegatePromise()).flush();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async close(): Promise<void> {
|
|
85
|
+
return (await this.getDelegatePromise()).close();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async read(options?: OutputReadOptions): Promise<string[]> {
|
|
89
|
+
return (await this.getDelegatePromise()).read(options);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
tail(callback: (line: string) => void, options?: OutputTailOptions): TailHandle {
|
|
93
|
+
let handle: TailHandle | null = null;
|
|
94
|
+
let closed = false;
|
|
95
|
+
|
|
96
|
+
this.getDelegatePromise().then((delegate) => {
|
|
97
|
+
if (closed) return;
|
|
98
|
+
handle = delegate.tail(callback, options);
|
|
99
|
+
for (const closeOp of this.pendingTailCloses) closeOp();
|
|
100
|
+
this.pendingTailCloses = [];
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
close: () => {
|
|
105
|
+
closed = true;
|
|
106
|
+
if (handle) {
|
|
107
|
+
handle.close();
|
|
108
|
+
} else {
|
|
109
|
+
this.pendingTailCloses.push(() => handle?.close());
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async stats(): Promise<OutputStats> {
|
|
116
|
+
return (await this.getDelegatePromise()).stats();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { RuntimeKindDescriptor, KindContext, RuntimeDescriptor } from '@vibesdotdev/runtime/schemas/kind';
|
|
2
|
+
import type { RuntimeScope } from '@vibesdotdev/runtime/schemas/scope';
|
|
3
|
+
import { OutputDescriptorSchema, type OutputDescriptor } from '../schemas/output.ts';
|
|
4
|
+
import type { FormatterImplementation } from './formatter.ts';
|
|
5
|
+
import { DefaultOutputImplementation } from './output.impl';
|
|
6
|
+
import type { OutputImplementation } from './output.types';
|
|
7
|
+
|
|
8
|
+
export type {
|
|
9
|
+
OutputReadOptions,
|
|
10
|
+
OutputTailOptions,
|
|
11
|
+
TailHandle,
|
|
12
|
+
OutputStats,
|
|
13
|
+
OutputImplementation
|
|
14
|
+
} from './output.types';
|
|
15
|
+
|
|
16
|
+
export interface OutputContext extends KindContext {
|
|
17
|
+
readonly runtime: unknown;
|
|
18
|
+
readonly formatter?: FormatterImplementation;
|
|
19
|
+
readonly workspacePath?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function resolveOutput(
|
|
23
|
+
candidates: RuntimeDescriptor[],
|
|
24
|
+
scope: RuntimeScope,
|
|
25
|
+
_context: KindContext
|
|
26
|
+
): OutputDescriptor | undefined {
|
|
27
|
+
const typed = candidates as OutputDescriptor[];
|
|
28
|
+
if (typed.length === 0) return undefined;
|
|
29
|
+
if (typed.length === 1) return typed[0];
|
|
30
|
+
|
|
31
|
+
const hardware = scope.hardware;
|
|
32
|
+
const matching = typed.filter((d) => {
|
|
33
|
+
if (!d.hardware || d.hardware.length === 0) return true;
|
|
34
|
+
return d.hardware.includes(hardware);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
if (matching.length === 0) return undefined;
|
|
38
|
+
const explicit = matching.filter((d) => d.hardware && d.hardware.length > 0);
|
|
39
|
+
if (explicit.length > 0) return explicit[0];
|
|
40
|
+
return matching[0];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const outputKind: RuntimeKindDescriptor<
|
|
44
|
+
OutputDescriptor,
|
|
45
|
+
OutputImplementation,
|
|
46
|
+
OutputContext
|
|
47
|
+
> = {
|
|
48
|
+
id: 'logging/output',
|
|
49
|
+
descriptorSchema: OutputDescriptorSchema,
|
|
50
|
+
defaultImplementation: DefaultOutputImplementation,
|
|
51
|
+
resolve: resolveOutput,
|
|
52
|
+
contexts: ['runtime/workspace-path']
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
declare module '@vibesdotdev/runtime/schemas/kind-types' {
|
|
56
|
+
interface KindTypeMap {
|
|
57
|
+
'logging/output': { descriptor: OutputDescriptor; impl: OutputImplementation };
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Type-only definitions to avoid circular dependencies.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { RuntimeLogEntry } from '../schemas/entry.ts';
|
|
8
|
+
import type { KindContext } from '@vibesdotdev/runtime/schemas/kind';
|
|
9
|
+
import type { FormatterImplementation } from './formatter.ts';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Options for reading from an output
|
|
13
|
+
*/
|
|
14
|
+
export interface OutputReadOptions {
|
|
15
|
+
/** Number of lines to read */
|
|
16
|
+
lines?: number;
|
|
17
|
+
/** Offset to start reading from */
|
|
18
|
+
offset?: number;
|
|
19
|
+
/** Filter pattern */
|
|
20
|
+
filter?: string | RegExp;
|
|
21
|
+
/** Whether to ignore case when filtering */
|
|
22
|
+
ignoreCase?: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Options for tailing an output
|
|
27
|
+
*/
|
|
28
|
+
export interface OutputTailOptions {
|
|
29
|
+
/** Number of lines to tail */
|
|
30
|
+
lines?: number;
|
|
31
|
+
/** Filter pattern */
|
|
32
|
+
filter?: string | RegExp;
|
|
33
|
+
/** Whether to ignore case when filtering */
|
|
34
|
+
ignoreCase?: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Handle for controlling a tail operation
|
|
39
|
+
*/
|
|
40
|
+
export interface TailHandle {
|
|
41
|
+
/** Close the tail operation */
|
|
42
|
+
close(): void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Statistics about an output
|
|
47
|
+
*/
|
|
48
|
+
export interface OutputStats {
|
|
49
|
+
/** Size in bytes */
|
|
50
|
+
size: number;
|
|
51
|
+
/** Number of lines (if applicable) */
|
|
52
|
+
lines?: number;
|
|
53
|
+
/** Last modification time */
|
|
54
|
+
modifiedAt?: Date;
|
|
55
|
+
/** Whether the output exists */
|
|
56
|
+
exists: boolean;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Context provided to output implementations.
|
|
61
|
+
*/
|
|
62
|
+
export interface OutputContext extends KindContext {
|
|
63
|
+
/** Runtime reference */
|
|
64
|
+
readonly runtime: unknown;
|
|
65
|
+
/** Formatter to use for this output */
|
|
66
|
+
readonly formatter?: FormatterImplementation;
|
|
67
|
+
/** Workspace path for file outputs */
|
|
68
|
+
readonly workspacePath?: string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Output implementation interface.
|
|
73
|
+
* Implementations write log entries to their destination.
|
|
74
|
+
*/
|
|
75
|
+
export interface OutputImplementation {
|
|
76
|
+
/** Unique identifier for this output */
|
|
77
|
+
readonly id: string;
|
|
78
|
+
|
|
79
|
+
/** Write a single log entry */
|
|
80
|
+
write(entry: RuntimeLogEntry): Promise<void>;
|
|
81
|
+
|
|
82
|
+
/** Write multiple entries in batch (optional optimization) */
|
|
83
|
+
writeBatch?(entries: RuntimeLogEntry[]): Promise<void>;
|
|
84
|
+
|
|
85
|
+
/** Write a raw line (optional) */
|
|
86
|
+
writeLine?(line: string): Promise<void>;
|
|
87
|
+
|
|
88
|
+
/** Flush any buffered entries */
|
|
89
|
+
flush(): Promise<void>;
|
|
90
|
+
|
|
91
|
+
/** Close the output and release resources */
|
|
92
|
+
close(): Promise<void>;
|
|
93
|
+
|
|
94
|
+
/** Rotate the output file (optional) */
|
|
95
|
+
rotate?(): Promise<{ archived: string }>;
|
|
96
|
+
|
|
97
|
+
/** Read entries from the output */
|
|
98
|
+
read(options?: OutputReadOptions): Promise<string[]>;
|
|
99
|
+
|
|
100
|
+
/** Tail the output for new entries */
|
|
101
|
+
tail(callback: (line: string) => void, options?: OutputTailOptions): TailHandle;
|
|
102
|
+
|
|
103
|
+
/** Get statistics about the output */
|
|
104
|
+
stats(): Promise<OutputStats>;
|
|
105
|
+
}
|