Skip to content

Documentation / @agentick/kernel / ContextFieldsExtractor

Type Alias: ContextFieldsExtractor()<TContext> ​

ContextFieldsExtractor<TContext> = (ctx) => Record<string, unknown>

Defined in: kernel/src/logger.ts:86

Function to extract fields from KernelContext for logging. Return an object with fields to include in every log entry.

Type Parameters ​

TContext ​

TContext extends KernelContext = KernelContext

The context type (extends KernelContext)

Parameters ​

ctx ​

TContext

Returns ​

Record<string, unknown>

Example ​

typescript
const myExtractor: ContextFieldsExtractor = (ctx) => ({
  userId: ctx.user?.id,
  tenantId: ctx.user?.tenantId,
  requestId: ctx.requestId,
});

See ​

composeContextFields - Combine multiple extractors

Released under the ISC License.