AIDK API Reference / aidk-kernel / ContextFieldsExtractor
Type Alias: ContextFieldsExtractor()<TContext> ​
ts
type ContextFieldsExtractor<TContext> = (ctx: TContext) => Record<string, unknown>;Defined in: packages/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 ​
| Type Parameter | Default type | Description |
|---|---|---|
TContext extends KernelContext | KernelContext | The context type (extends KernelContext) |
Parameters ​
| Parameter | Type |
|---|---|
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