autotel-cloudflare 2.18.12 → 2.18.15

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 CHANGED
@@ -37,6 +37,25 @@ pnpm add autotel-cloudflare
37
37
  yarn add autotel-cloudflare
38
38
  ```
39
39
 
40
+ ## Quickstart: Structured logging in a Cloudflare Worker
41
+
42
+ For just structured logs (no tracing setup required), import from `autotel-cloudflare/logger`:
43
+
44
+ ```ts
45
+ import { createEdgeLogger } from 'autotel-cloudflare/logger'
46
+
47
+ const log = createEdgeLogger('my-worker', { level: 'info' })
48
+
49
+ export default {
50
+ async fetch() {
51
+ log.info({ user_id: 'u1' }, 'request handled')
52
+ return new Response('ok')
53
+ },
54
+ }
55
+ ```
56
+
57
+ `autotel-cloudflare/logger` is the edge-clean entry: it re-exports `createEdgeLogger` from `autotel-edge/logger` plus the Cloudflare execution-logger helpers (`createWorkersLogger`, `getRequestLogger`, `getQueueLogger`). The root `autotel-cloudflare` import pulls in tracing, `AsyncLocalStorage`, and the wrappers — only use it when you want spans.
58
+
40
59
  ## Quick Start
41
60
 
42
61
  ### 1. Configure Cloudflare Native OTel (wrangler.toml)
@@ -444,7 +463,7 @@ export default wrapModule(
444
463
  ## Entry Points (Tree-Shaking)
445
464
 
446
465
  ```typescript
447
- // Main export (everything)
466
+ // Main export (everything — pulls AsyncLocalStorage, needs nodejs_compat)
448
467
  import { wrapModule, trace, instrument } from 'autotel-cloudflare'
449
468
 
450
469
  // Tree-shakeable entry points
@@ -456,6 +475,31 @@ import { createEdgeLogger } from 'autotel-cloudflare/logger'
456
475
  import { createTraceCollector } from 'autotel-cloudflare/testing'
457
476
  ```
458
477
 
478
+ ## Cloudflare compatibility
479
+
480
+ Workers run on V8 isolates, not Node. Anything that transitively imports `node:async_hooks` (used by `AsyncLocalStorageContextManager` for span context) or `node:buffer` requires `compatibility_flags = ["nodejs_compat"]` in your `wrangler.toml`. The `/logger` subpath stays clear of those.
481
+
482
+ | Entry | Edge-safe without `nodejs_compat`? | Notes |
483
+ | --- | --- | --- |
484
+ | `autotel-cloudflare` | No — needs `nodejs_compat` | Pulls `AsyncLocalStorage` (span context) and `Buffer` transitively via `autotel-edge` root |
485
+ | `autotel-cloudflare/logger` | Yes | Edge-clean. `createEdgeLogger`, `createWorkersLogger`, `getRequestLogger`, `getQueueLogger`, `getWorkflowLogger`, `getActorLogger` |
486
+ | `autotel-cloudflare/bindings` | No — needs `nodejs_compat` | Wrappers create spans, require context manager |
487
+ | `autotel-cloudflare/handlers` | No — needs `nodejs_compat` | DO/Workflow wrappers create spans |
488
+ | `autotel-cloudflare/sampling` | Yes | Pure samplers, no runtime imports |
489
+ | `autotel-cloudflare/events` | No — needs `nodejs_compat` | Pulls trace context for correlation |
490
+ | `autotel-cloudflare/testing` | Yes (test-only) | Collectors live in test runtime; do not ship to Workers |
491
+ | `autotel-cloudflare/actors` | No — needs `nodejs_compat` | Builds on DO wrappers |
492
+ | `autotel-cloudflare/agents` | No — needs `nodejs_compat` | Builds on DO wrappers |
493
+ | `autotel-cloudflare/parse-error` | Yes | Pure error normaliser |
494
+
495
+ Rule of thumb: if you only need logs, import `autotel-cloudflare/logger` and skip `nodejs_compat`. If you want spans, add `nodejs_compat` and import from the root.
496
+
497
+ ## See also
498
+
499
+ - [autotel-edge](../autotel-edge) — vendor-agnostic foundation re-exported by this package
500
+ - [autotel](../autotel) — Node.js entry, full SDK with auto-instrumentation
501
+ - [autotel-drizzle](../autotel-drizzle) — Drizzle ORM spans (Node only)
502
+
459
503
  ## Testing
460
504
 
461
505
  ```typescript
@@ -1,4 +1,4 @@
1
- import { getExecutionLogger } from 'autotel-edge';
1
+ import { getExecutionLogger } from 'autotel-edge/logger';
2
2
 
3
3
  // src/execution-logger.ts
4
4
  function isRecord(value) {
@@ -59,5 +59,5 @@ function getActorLogger(ctx, options) {
59
59
  }
60
60
 
61
61
  export { createWorkersLogger, getActorLogger, getQueueLogger, getRequestLogger, getWorkflowLogger };
62
- //# sourceMappingURL=chunk-C3QLNZRK.js.map
63
- //# sourceMappingURL=chunk-C3QLNZRK.js.map
62
+ //# sourceMappingURL=chunk-RVVMMPWN.js.map
63
+ //# sourceMappingURL=chunk-RVVMMPWN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/execution-logger.ts"],"names":[],"mappings":";;;AAqBA,SAAS,SAAS,KAAA,EAAkD;AAClE,EAAA,OAAO,OAAO,UAAU,QAAA,IAAY,KAAA,KAAU,QAAQ,CAAC,KAAA,CAAM,QAAQ,KAAK,CAAA;AAC5E;AAEA,SAAS,cAAA,CACP,SACA,OAAA,EACoC;AACpC,EAAA,IAAI,CAAC,OAAA,IAAW,OAAA,CAAQ,MAAA,KAAW,GAAG,OAAO,MAAA;AAE7C,EAAA,MAAM,SAAA,GAAY,IAAI,GAAA,CAAI,OAAA,CAAQ,GAAA,CAAI,CAAC,CAAA,KAAM,CAAA,CAAE,WAAA,EAAa,CAAC,CAAA;AAC7D,EAAA,MAAM,MAA8B,EAAC;AACrC,EAAA,OAAA,CAAQ,OAAA,CAAQ,CAAC,KAAA,EAAO,GAAA,KAAQ;AAC9B,IAAA,IAAI,SAAA,CAAU,GAAA,CAAI,GAAA,CAAI,WAAA,EAAa,CAAA,EAAG;AACpC,MAAA,GAAA,CAAI,GAAG,CAAA,GAAI,KAAA;AAAA,IACb;AAAA,EACF,CAAC,CAAA;AAED,EAAA,OAAO,OAAO,IAAA,CAAK,GAAG,CAAA,CAAE,MAAA,GAAS,IAAI,GAAA,GAAM,MAAA;AAC7C;AAEA,SAAS,cAAc,OAAA,EAA2C;AAChE,EAAA,MAAM,EAAA,GAAK,OAAA,CAAQ,GAAA,CAAI,OAAA,EAAS,IAAI,CAAA;AACpC,EAAA,IAAI,CAAC,QAAA,CAAS,EAAE,CAAA,SAAU,EAAC;AAE3B,EAAA,MAAM,MAA+B,EAAC;AACtC,EAAA,IAAI,OAAO,EAAA,CAAG,IAAA,KAAS,QAAA,EAAU,GA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AO,GAAA;AACT;AAEO,SAAS,gBAAA,CACd,KACA,OAAA,EACiB;AACjB,EAAA,OAAO,kBAAA,CAAmB,KAAK,OAAO,CAAA;AACxC;AAEO,SAAS,cAAA,CACd,KACA,OAAA,EACiB;AACjB,EAAA,OAAO,kBAAA,CAAmB,KAAK,OAAO,CAAA;AACxC;AAEO,SAAS,iBAAA,CACd,KACA,OAAA,EACiB;AACjB,EAAA,OAAO,kBAAA,CAAmB,KAAK,OAAO,CAAA;AACxC;AAEO,SAAS,cAAA,CACd,KACA,OAAA,EACiB;AACjB,EAAA,OAAO,kBAAA,CAAmB,KAAK,OAAO,CAAA;AACxC","file":"chunk-RVVMMPWN.js","sourcesContent":["import {\n type ExecutionLogger,\n type ExecutionLoggerOptions,\n type ExecutionLogSnapshot,\n getExecutionLogger,\n type TraceContext,\n} from 'autotel-edge/logger';\n\nexport type {\n ExecutionLogger,\n ExecutionLoggerOptions,\n ExecutionLogSnapshot,\n};\n\nexport interface WorkersLoggerOptions {\n /** Override derived request id (default: cf-ray header value when present). */\n requestId?: string;\n /** Optional request header allowlist to include in logger context. */\n headers?: string[];\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction collectHeaders(\n headers: Headers,\n include: string[] | undefined,\n): Record<string, string> | undefined {\n if (!include || include.length === 0) return undefined;\n\n const allowlist = new Set(include.map((h) => h.toLowerCase()));\n const out: Record<string, string> = {};\n headers.forEach((value, key) => {\n if (allowlist.has(key.toLowerCase())) {\n out[key] = value;\n }\n });\n\n return Object.keys(out).length > 0 ? out : undefined;\n}\n\nfunction pickCfContext(request: Request): Record<string, unknown> {\n const cf = Reflect.get(request, 'cf');\n if (!isRecord(cf)) return {};\n\n const out: Record<string, unknown> = {};\n if (typeof cf.colo === 'string') out.colo = cf.colo;\n if (typeof cf.country === 'string') out.country = cf.country;\n if (typeof cf.asn === 'number') out.asn = cf.asn;\n if (typeof cf.city === 'string') out.city = cf.city;\n if (typeof cf.region === 'string') out.region = cf.region;\n return out;\n}\n\n/**\n * Create an execution logger pre-populated with common request context.\n * Best used from fetch handlers that already run inside autotel span context.\n */\nexport function createWorkersLogger(\n request: Request,\n options: WorkersLoggerOptions = {},\n ctx?: TraceContext,\n): ExecutionLogger {\n const log = getExecutionLogger(ctx);\n const url = new URL(request.url);\n const cfRay = request.headers.get('cf-ray') ?? undefined;\n const traceparent = request.headers.get('traceparent') ?? undefined;\n\n log.set({\n request: {\n method: request.method,\n path: url.pathname,\n url: request.url,\n requestId: options.requestId ?? cfRay,\n headers: collectHeaders(request.headers, options.headers),\n },\n cfRay,\n traceparent,\n ...pickCfContext(request),\n });\n\n return log;\n}\n\nexport function getRequestLogger(\n ctx?: TraceContext,\n options?: ExecutionLoggerOptions,\n): ExecutionLogger {\n return getExecutionLogger(ctx, options);\n}\n\nexport function getQueueLogger(\n ctx?: TraceContext,\n options?: ExecutionLoggerOptions,\n): ExecutionLogger {\n return getExecutionLogger(ctx, options);\n}\n\nexport function getWorkflowLogger(\n ctx?: TraceContext,\n options?: ExecutionLoggerOptions,\n): ExecutionLogger {\n return getExecutionLogger(ctx, options);\n}\n\nexport function getActorLogger(\n ctx?: TraceContext,\n options?: ExecutionLoggerOptions,\n): ExecutionLogger {\n return getExecutionLogger(ctx, options);\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { ConfigurationOption, ExecutionLogger } from 'autotel-edge';
1
+ import { ConfigurationOption } from 'autotel-edge';
2
2
  export * from 'autotel-edge';
3
- export { ExecutionLogSnapshot, ExecutionLogger, ExecutionLoggerOptions } from 'autotel-edge';
4
- import { W as WorkersLoggerOptions } from './logger-DGS3kP-A.js';
5
- export { c as createWorkersLogger, g as getActorLogger, a as getQueueLogger, b as getRequestLogger, d as getWorkflowLogger } from './logger-DGS3kP-A.js';
3
+ import { W as WorkersLoggerOptions } from './logger-Cm_73k3-.js';
4
+ export { c as createWorkersLogger, g as getActorLogger, a as getQueueLogger, b as getRequestLogger, d as getWorkflowLogger } from './logger-Cm_73k3-.js';
5
+ import { ExecutionLogger } from 'autotel-edge/logger';
6
+ export { ExecutionLogSnapshot, ExecutionLogger, ExecutionLoggerOptions } from 'autotel-edge/logger';
6
7
  export { instrumentDO, instrumentWorkflow } from './handlers.js';
7
8
  export { instrumentAI, instrumentAnalyticsEngine, instrumentBindings, instrumentBrowserRendering, instrumentD1, instrumentHyperdrive, instrumentImages, instrumentKV, instrumentQueueProducer, instrumentR2, instrumentRateLimiter, instrumentServiceBinding, instrumentVectorize } from './bindings.js';
8
- import 'autotel-edge/logger';
9
9
 
10
10
  /**
11
11
  * Handler instrumentation for Cloudflare Workers
package/dist/index.js CHANGED
@@ -2,8 +2,8 @@ import { instrumentBindings } from './chunk-KAUHT25H.js';
2
2
  export { instrumentAI, instrumentAnalyticsEngine, instrumentBindings, instrumentBrowserRendering, instrumentD1, instrumentHyperdrive, instrumentImages, instrumentKV, instrumentQueueProducer, instrumentR2, instrumentRateLimiter, instrumentServiceBinding, instrumentVectorize } from './chunk-KAUHT25H.js';
3
3
  import { instrumentDO } from './chunk-MIDMNKDC.js';
4
4
  export { instrumentDO, instrumentWorkflow } from './chunk-MIDMNKDC.js';
5
- import { createWorkersLogger } from './chunk-C3QLNZRK.js';
6
- export { createWorkersLogger, getActorLogger, getQueueLogger, getRequestLogger, getWorkflowLogger } from './chunk-C3QLNZRK.js';
5
+ import { createWorkersLogger } from './chunk-RVVMMPWN.js';
6
+ export { createWorkersLogger, getActorLogger, getQueueLogger, getRequestLogger, getWorkflowLogger } from './chunk-RVVMMPWN.js';
7
7
  import { wrap, unwrap, proxyExecutionContext } from './chunk-O4IYKWPJ.js';
8
8
  import { createInitialiser, getActiveConfig, shouldInstrumentPath, setConfig, WorkerTracerProvider, WorkerTracer, getServiceForPath } from 'autotel-edge';
9
9
  export * from 'autotel-edge';
@@ -1,5 +1,4 @@
1
- import 'autotel-edge/logger';
2
- import { TraceContext, ExecutionLogger, ExecutionLoggerOptions } from 'autotel-edge';
1
+ import { TraceContext, ExecutionLogger, ExecutionLoggerOptions } from 'autotel-edge/logger';
3
2
 
4
3
  interface WorkersLoggerOptions {
5
4
  /** Override derived request id (default: cf-ray header value when present). */
package/dist/logger.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export * from 'autotel-edge/logger';
2
- export { g as getActorLogger, a as getQueueLogger, b as getRequestLogger, d as getWorkflowLogger } from './logger-DGS3kP-A.js';
3
- export { ExecutionLogSnapshot, ExecutionLogger, ExecutionLoggerOptions } from 'autotel-edge';
2
+ export { ExecutionLogSnapshot, ExecutionLogger, ExecutionLoggerOptions } from 'autotel-edge/logger';
3
+ export { g as getActorLogger, a as getQueueLogger, b as getRequestLogger, d as getWorkflowLogger } from './logger-Cm_73k3-.js';
package/dist/logger.js CHANGED
@@ -1,4 +1,4 @@
1
- export { getActorLogger, getQueueLogger, getRequestLogger, getWorkflowLogger } from './chunk-C3QLNZRK.js';
1
+ export { getActorLogger, getQueueLogger, getRequestLogger, getWorkflowLogger } from './chunk-RVVMMPWN.js';
2
2
  export * from 'autotel-edge/logger';
3
3
  //# sourceMappingURL=logger.js.map
4
4
  //# sourceMappingURL=logger.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autotel-cloudflare",
3
- "version": "2.18.12",
3
+ "version": "2.18.15",
4
4
  "description": "The #1 OpenTelemetry package for Cloudflare Workers - complete bindings coverage, native CF OTel integration, advanced sampling",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -73,21 +73,27 @@
73
73
  "license": "MIT",
74
74
  "dependencies": {
75
75
  "@opentelemetry/api": "^1.9.1",
76
- "@opentelemetry/resources": "^2.7.1",
77
- "autotel-edge": "3.16.10"
76
+ "@opentelemetry/resources": "^2.7.1"
78
77
  },
79
78
  "peerDependencies": {
80
- "@cloudflare/workers-types": "^4.20260511.1"
79
+ "@cloudflare/workers-types": "^4.20260529.1",
80
+ "autotel-edge": "3.16.12"
81
+ },
82
+ "peerDependenciesMeta": {
83
+ "autotel-edge": {
84
+ "optional": false
85
+ }
81
86
  },
82
87
  "devDependencies": {
83
- "@cloudflare/workers-types": "^4.20260511.1",
88
+ "@cloudflare/workers-types": "^4.20260529.1",
84
89
  "@opentelemetry/context-async-hooks": "^2.7.1",
85
- "@types/node": "^25.7.0",
90
+ "@types/node": "^25.9.1",
86
91
  "rimraf": "^6.1.3",
87
92
  "tsup": "^8.5.1",
88
93
  "typescript": "^6.0.3",
89
- "vitest": "^4.1.6",
90
- "vitest-mock-extended": "^4.0.0"
94
+ "vitest": "^4.1.7",
95
+ "vitest-mock-extended": "^4.0.0",
96
+ "autotel-edge": "3.16.12"
91
97
  },
92
98
  "repository": {
93
99
  "type": "git",
@@ -4,7 +4,7 @@ import {
4
4
  type ExecutionLogSnapshot,
5
5
  getExecutionLogger,
6
6
  type TraceContext,
7
- } from 'autotel-edge';
7
+ } from 'autotel-edge/logger';
8
8
 
9
9
  export type {
10
10
  ExecutionLogger,
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/execution-logger.ts"],"names":[],"mappings":";;;AAqBA,SAAS,SAAS,KAAA,EAAkD;AAClE,EAAA,OAAO,OAAO,UAAU,QAAA,IAAY,KAAA,KAAU,QAAQ,CAAC,KAAA,CAAM,QAAQ,KAAK,CAAA;AAC5E;AAEA,SAAS,cAAA,CACP,SACA,OAAA,EACoC;AACpC,EAAA,IAAI,CAAC,OAAA,IAAW,OAAA,CAAQ,MAAA,KAAW,GAAG,OAAO,MAAA;AAE7C,EAAA,MAAM,SAAA,GAAY,IAAI,GAAA,CAAI,OAAA,CAAQ,GAAA,CAAI,CAAC,CAAA,KAAM,CAAA,CAAE,WAAA,EAAa,CAAC,CAAA;AAC7D,EAAA,MAAM,MAA8B,EAAC;AACrC,EAAA,OAAA,CAAQ,OAAA,CAAQ,CAAC,KAAA,EAAO,GAAA,KAAQ;AAC9B,IAAA,IAAI,SAAA,CAAU,GAAA,CAAI,GAAA,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WAAA,GAAc,OAAA,CAAQ,OAAA,CAAQ,GAAA,CAAI,aAAa,CAAA,IAAK,MAAA;AAE1D,EAAA,GAAA,CAAI,GAAA,CAAI;AAAA,IACN,OAAA,EAAS;AAAA,MACP,QAAQ,OAAA,CAAQ,MAAA;AAAA,MAChB,MAAM,GAAA,CAAI,QAAA;AAAA,MACV,KAAK,OAAA,CAAQ,GAAA;AAAA,MACb,SAAA,EAAW,QAAQ,SAAA,IAAa,KAAA;AAAA,MAChC,OAAA,EAAS,cAAA,CAAe,OAAA,CAAQ,OAAA,EAAS,QAAQ,OAAO;AAAA,KAC1D;AAAA,IACA,KAAA;AAAA,IACA,WAAA;AAAA,IACA,GAAG,cAAc,OAAO;AAAA,GACzB,CAAA;AAED,EAAA,OAAO,GAAA;AACT;AAEO,SAAS,gBAAA,CACd,KACA,OAAA,EACiB;AACjB,EAAA,OAAO,kBAAA,CAAmB,KAAK,OAAO,CAAA;AACxC;AAEO,SAAS,cAAA,CACd,KACA,OAAA,EACiB;AACjB,EAAA,OAAO,kBAAA,CAAmB,KAAK,OAAO,CAAA;AACxC;AAEO,SAAS,iBAAA,CACd,KACA,OAAA,EACiB;AACjB,EAAA,OAAO,kBAAA,CAAmB,KAAK,OAAO,CAAA;AACxC;AAEO,SAAS,cAAA,CACd,KACA,OAAA,EACiB;AACjB,EAAA,OAAO,kBAAA,CAAmB,KAAK,OAAO,CAAA;AACxC","file":"chunk-C3QLNZRK.js","sourcesContent":["import {\n type ExecutionLogger,\n type ExecutionLoggerOptions,\n type ExecutionLogSnapshot,\n getExecutionLogger,\n type TraceContext,\n} from 'autotel-edge';\n\nexport type {\n ExecutionLogger,\n ExecutionLoggerOptions,\n ExecutionLogSnapshot,\n};\n\nexport interface WorkersLoggerOptions {\n /** Override derived request id (default: cf-ray header value when present). */\n requestId?: string;\n /** Optional request header allowlist to include in logger context. */\n headers?: string[];\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction collectHeaders(\n headers: Headers,\n include: string[] | undefined,\n): Record<string, string> | undefined {\n if (!include || include.length === 0) return undefined;\n\n const allowlist = new Set(include.map((h) => h.toLowerCase()));\n const out: Record<string, string> = {};\n headers.forEach((value, key) => {\n if (allowlist.has(key.toLowerCase())) {\n out[key] = value;\n }\n });\n\n return Object.keys(out).length > 0 ? out : undefined;\n}\n\nfunction pickCfContext(request: Request): Record<string, unknown> {\n const cf = Reflect.get(request, 'cf');\n if (!isRecord(cf)) return {};\n\n const out: Record<string, unknown> = {};\n if (typeof cf.colo === 'string') out.colo = cf.colo;\n if (typeof cf.country === 'string') out.country = cf.country;\n if (typeof cf.asn === 'number') out.asn = cf.asn;\n if (typeof cf.city === 'string') out.city = cf.city;\n if (typeof cf.region === 'string') out.region = cf.region;\n return out;\n}\n\n/**\n * Create an execution logger pre-populated with common request context.\n * Best used from fetch handlers that already run inside autotel span context.\n */\nexport function createWorkersLogger(\n request: Request,\n options: WorkersLoggerOptions = {},\n ctx?: TraceContext,\n): ExecutionLogger {\n const log = getExecutionLogger(ctx);\n const url = new URL(request.url);\n const cfRay = request.headers.get('cf-ray') ?? undefined;\n const traceparent = request.headers.get('traceparent') ?? undefined;\n\n log.set({\n request: {\n method: request.method,\n path: url.pathname,\n url: request.url,\n requestId: options.requestId ?? cfRay,\n headers: collectHeaders(request.headers, options.headers),\n },\n cfRay,\n traceparent,\n ...pickCfContext(request),\n });\n\n return log;\n}\n\nexport function getRequestLogger(\n ctx?: TraceContext,\n options?: ExecutionLoggerOptions,\n): ExecutionLogger {\n return getExecutionLogger(ctx, options);\n}\n\nexport function getQueueLogger(\n ctx?: TraceContext,\n options?: ExecutionLoggerOptions,\n): ExecutionLogger {\n return getExecutionLogger(ctx, options);\n}\n\nexport function getWorkflowLogger(\n ctx?: TraceContext,\n options?: ExecutionLoggerOptions,\n): ExecutionLogger {\n return getExecutionLogger(ctx, options);\n}\n\nexport function getActorLogger(\n ctx?: TraceContext,\n options?: ExecutionLoggerOptions,\n): ExecutionLogger {\n return getExecutionLogger(ctx, options);\n}\n"]}