diff --git a/custom-logger/output.txt b/custom-logger/output.txt new file mode 100644 index 00000000..1da30030 --- /dev/null +++ b/custom-logger/output.txt @@ -0,0 +1,332 @@ +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +@@ Note to reader: @@ +@@ @@ +@@ This is the full log output of running the sample. @@ +@@ If you want to find the specific thing logged from @@ +@@ the Activity, just @@ +@@ control f for This-is-the-error-info @@ +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + + npm run start.watch + + +> temporal-custom-logger@0.1.0 start.watch +> nodemon src/worker.ts + +[nodemon] 3.1.7 +[nodemon] to restart at any time, enter `rs` +[nodemon] watching path(s): src/**/* +[nodemon] watching extensions: ts +[nodemon] starting `ts-node src/worker.ts` +2025-01-27T20:40:36.282Z [worker] info: Creating worker { + sdkComponent: 'worker', + taskQueue: 'custom-logger', + options: { + namespace: 'default', + identity: '56408@Mac.attlocal.net', + useVersioning: false, + buildId: undefined, + shutdownGraceTime: 0, + enableNonLocalActivities: true, + maxConcurrentWorkflowTaskPolls: 10, + maxConcurrentActivityTaskPolls: 10, + stickyQueueScheduleToStartTimeout: '10s', + maxHeartbeatThrottleInterval: '60s', + defaultHeartbeatThrottleInterval: '30s', + isolateExecutionTimeout: '5s', + workflowThreadPoolSize: 1, + maxCachedWorkflows: 2310, + showStackTraceSources: false, + debugMode: false, + interceptors: { activity: [], workflowModules: [] }, + nonStickyToStickyPollRatio: 0.2, + sinks: { + __temporal_logger: { + trace: { fn: [Function: fn] }, + debug: { fn: [Function: fn] }, + info: { fn: [Function: fn] }, + warn: { fn: [Function: fn] }, + error: { fn: [Function: fn] } + } + }, + workflowsPath: '/Users/grantsmith/forks/samples-typescript/custom-logger/src/workflows/index.ts', + activities: Map(1) { 'greet' => [AsyncFunction: greet] }, + taskQueue: 'custom-logger', + tuner: { + workflowTaskSlotSupplier: { type: 'fixed-size', numSlots: 40 }, + activityTaskSlotSupplier: { type: 'fixed-size', numSlots: 100 }, + localActivityTaskSlotSupplier: { type: 'fixed-size', numSlots: 100 } + }, + reuseV8Context: true, + shutdownGraceTimeMs: 0, + shutdownForceTimeMs: undefined, + stickyQueueScheduleToStartTimeoutMs: 10000, + isolateExecutionTimeoutMs: 5000, + maxHeartbeatThrottleIntervalMs: 60000, + defaultHeartbeatThrottleIntervalMs: 30000, + loadedDataConverter: { + payloadConverter: DefaultPayloadConverter { + converterByEncoding: Map(3) { + 'binary/null' => [UndefinedPayloadConverter], + 'binary/plain' => [BinaryPayloadConverter], + 'json/plain' => [JsonPayloadConverter] + }, + converters: [ + [UndefinedPayloadConverter], + [BinaryPayloadConverter], + [JsonPayloadConverter] + ] + }, + failureConverter: DefaultFailureConverter { + options: { encodeCommonAttributes: false } + }, + payloadCodecs: [] + } + } +} +2025-01-27T20:40:36.577Z [worker] info: asset workflow-bundle-b55e232a2372bf65f9ec.js 957 KiB [emitted] [immutable] (name: main) +runtime modules 937 bytes 4 modules +modules by path ../node_modules/.pnpm/ 280 KiB + modules by path ../node_modules/.pnpm/@temporalio+common@1.11.6/node_modules/@temporal...(truncated) 95.3 KiB 23 modules + modules by path ../node_modules/.pnpm/@temporalio+workflow@1.11.6/node_modules/@tempor...(truncated) 138 KiB + ../node_modules/.pnpm/@temporalio+workflow@1.11.6/node_modules/@temporalio/workf...(truncated) 8.38 KiB [built] [code generated] + ../node_modules/.pnpm/@temporalio+workflow@1.11.6/node_modules/@temporalio/workf...(truncated) 4.09 KiB [built] [code generated] + + 17 modules + ../node_modules/.pnpm/long@5.2.3/node_modules/long/umd/index.js 43.1 KiB [built] [code generated] + ../node_modules/.pnpm/ms@3.0.0-canary.1/node_modules/ms/dist/index.cjs 3.41 KiB [built] [code generated] +modules by path ./src/workflows/ 746 bytes + ./src/workflows/index-autogenerated-entrypoint.cjs 465 bytes [built] [code generated] + ./src/workflows/index.ts 281 bytes [built] [code generated] +__temporal_custom_payload_converter (ignored) 15 bytes [built] [code generated] +__temporal_custom_failure_converter (ignored) 15 bytes [built] [code generated] +webpack 5.96.1 compiled successfully in 200 ms { sdkComponent: 'worker', taskQueue: 'custom-logger' } +2025-01-27T20:40:36.578Z [worker] info: Workflow bundle created { sdkComponent: 'worker', taskQueue: 'custom-logger', size: '0.93MB' } +2025-01-27T20:40:36.637Z [worker] info: Initializing worker { + sdkComponent: 'core', + namespace: 'default', + taskQueue: 'custom-logger' +} +2025-01-27T20:40:36.638Z [worker] info: Worker state changed { + sdkComponent: 'worker', + taskQueue: 'custom-logger', + state: 'RUNNING' +} +2025-01-27T20:40:38.993Z [worker] debug: New WFT { + sdkComponent: 'core', + runId: 'c1d2e101-d310-4fe3-9c43-964b98c8f1ba', + action: 'NewWft(PermittedWft(PreparedWFT { task_token: TaskToken(CiQ0NmM0OWQ5Zi03ODQ4LTQwNjktYjMwZi01YjU2NTJmM2VjM2USHndvcmtmbG93LThGS3FabWkxXzhGX0JyNEdIN1JENhokYzFkMmUxMDEtZDMxMC00ZmUzLTljNDMtOTY0Yjk4YzhmMWJhIAIoAUoICAEQtYBAGAFQA2IMCMbe37wGENCrntkD), attempt: 1, execution: WorkflowExecution { workflow_id: "workflow-8FKqZmi1_8F_Br4GH7RD6", run_id: "c1d2e101-d310-4fe3-9c43-964b98c8f1ba" }, workflow_type: "logSampleWorkflow", legacy_query: None, query_requests: [], update: HistoryUpdate(previous_started_event_id: 0, started_id: 3, length: 3, first_event_id: Some(1)), messages: [] }))' +} +2025-01-27T20:40:38.993Z [workflow] debug: Applying new workflow task from server { + sdkComponent: 'core', + workflowId: 'workflow-8FKqZmi1_8F_Br4GH7RD6', + taskToken: 'CiQ0NmM0OWQ5Zi03ODQ4LTQwNjktYjMwZi01YjU2NTJmM2VjM2USHndvcmtmbG93LThGS3FabWkxXzhGX0JyNEdIN1JENhokYzFkMmUxMDEtZDMxMC00ZmUzLTljNDMtOTY0Yjk4YzhmMWJhIAIoAUoICAEQtYBAGAFQA2IMCMbe37wGENCrntkD', + action: 'NewWft(PermittedWft(PreparedWFT { task_token: TaskToken(CiQ0NmM0OWQ5Zi03ODQ4LTQwNjktYjMwZi01YjU2NTJmM2VjM2USHndvcmtmbG93LThGS3FabWkxXzhGX0JyNEdIN1JENhokYzFkMmUxMDEtZDMxMC00ZmUzLTljNDMtOTY0Yjk4YzhmMWJhIAIoAUoICAEQtYBAGAFQA2IMCMbe37wGENCrntkD), attempt: 1, execution: WorkflowExecution { workflow_id: "workflow-8FKqZmi1_8F_Br4GH7RD6", run_id: "c1d2e101-d310-4fe3-9c43-964b98c8f1ba" }, workflow_type: "logSampleWorkflow", legacy_query: None, query_requests: [], update: HistoryUpdate(previous_started_event_id: 0, started_id: 3, length: 3, first_event_id: Some(1)), messages: [] }))', + messages: '[]', + update: 'HistoryUpdate(previous_started_event_id: 0, started_id: 3, length: 3, first_event_id: Some(1))', + runId: 'c1d2e101-d310-4fe3-9c43-964b98c8f1ba', + hasLegacyQuery: 'false', + attempt: '1' +} +2025-01-27T20:40:38.993Z [workflow] debug: Driven WF start { + sdkComponent: 'core', + workflowId: 'workflow-8FKqZmi1_8F_Br4GH7RD6', + nextEvent: 'Some(HistoryEvent { event_id: 2, event_time: Some(Timestamp { seconds: 1738010438, nanos: 991419000 }), event_type: WorkflowTaskScheduled, version: 0, task_id: 1048621, worker_may_ignore: false, user_metadata: None, links: [], attributes: Some(WorkflowTaskScheduledEventAttributes(WorkflowTaskScheduledEventAttributes { task_queue: Some(TaskQueue { name: "custom-logger", kind: Normal, normal_name: "" }), start_to_close_timeout: Some(Duration { seconds: 10, nanos: 0 }), attempt: 1 })) })', + runId: 'c1d2e101-d310-4fe3-9c43-964b98c8f1ba', + event: 'HistoryEvent(id: 1, WorkflowExecutionStarted)', + action: 'NewWft(PermittedWft(PreparedWFT { task_token: TaskToken(CiQ0NmM0OWQ5Zi03ODQ4LTQwNjktYjMwZi01YjU2NTJmM2VjM2USHndvcmtmbG93LThGS3FabWkxXzhGX0JyNEdIN1JENhokYzFkMmUxMDEtZDMxMC00ZmUzLTljNDMtOTY0Yjk4YzhmMWJhIAIoAUoICAEQtYBAGAFQA2IMCMbe37wGENCrntkD), attempt: 1, execution: WorkflowExecution { workflow_id: "workflow-8FKqZmi1_8F_Br4GH7RD6", run_id: "c1d2e101-d310-4fe3-9c43-964b98c8f1ba" }, workflow_type: "logSampleWorkflow", legacy_query: None, query_requests: [], update: HistoryUpdate(previous_started_event_id: 0, started_id: 3, length: 3, first_event_id: Some(1)), messages: [] }))' +} +2025-01-27T20:40:38.993Z [worker] debug: Sending activation to lang { + sdkComponent: 'core', + activation: 'WorkflowActivation(run_id: c1d2e101-d310-4fe3-9c43-964b98c8f1ba, is_replaying: false, jobs: InitializeWorkflow)', + taskQueue: 'custom-logger' +} +2025-01-27T20:40:39.012Z [workflow] debug: Workflow started { + sdkComponent: 'worker', + taskQueue: 'custom-logger', + namespace: 'default', + workflowId: 'workflow-8FKqZmi1_8F_Br4GH7RD6', + runId: 'c1d2e101-d310-4fe3-9c43-964b98c8f1ba', + workflowType: 'logSampleWorkflow' +} +2025-01-27T20:40:39.013Z [workflow] debug: wf bridge iteration fetch { + sdkComponent: 'core', + runId: 'c1d2e101-d310-4fe3-9c43-964b98c8f1ba', + taskQueue: 'custom-logger', + workflowId: 'workflow-8FKqZmi1_8F_Br4GH7RD6', + completion: 'WorkflowActivationCompletion(run_id: c1d2e101-d310-4fe3-9c43-964b98c8f1ba, status: Success(ScheduleActivity(1, greet) ))', + inCmds: '[ScheduleActivity(1, greet)]' +} +2025-01-27T20:40:39.013Z [workflow] debug: handling command { + sdkComponent: 'core', + workflowId: 'workflow-8FKqZmi1_8F_Br4GH7RD6', + state: 'ScheduleCommandCreated', + machineName: 'ActivityMachine', + completion: 'WorkflowActivationCompletion(run_id: c1d2e101-d310-4fe3-9c43-964b98c8f1ba, status: Success(ScheduleActivity(1, greet) ))', + runId: 'c1d2e101-d310-4fe3-9c43-964b98c8f1ba', + taskQueue: 'custom-logger', + commandType: 'ScheduleActivityTask' +} +2025-01-27T20:40:39.013Z [workflow] debug: prepared commands { + sdkComponent: 'core', + workflowId: 'workflow-8FKqZmi1_8F_Br4GH7RD6', + runId: 'c1d2e101-d310-4fe3-9c43-964b98c8f1ba', + completion: 'WorkflowActivationCompletion(run_id: c1d2e101-d310-4fe3-9c43-964b98c8f1ba, status: Success(ScheduleActivity(1, greet) ))', + commands: '[Cmd&Machine(ScheduleActivityTask)]', + taskQueue: 'custom-logger' +} +2025-01-27T20:40:39.013Z [workflow] debug: Sending responses to server { + sdkComponent: 'core', + commands: '[ScheduleActivityTask]', + messages: '[]', + runId: 'c1d2e101-d310-4fe3-9c43-964b98c8f1ba', + completion: 'WorkflowActivationCompletion(run_id: c1d2e101-d310-4fe3-9c43-964b98c8f1ba, status: Success(ScheduleActivity(1, greet) ))', + workflowId: 'workflow-8FKqZmi1_8F_Br4GH7RD6', + forceNewWft: false, + taskQueue: 'custom-logger', + queryResponses: '[]' +} +2025-01-27T20:40:39.014Z [workflow] debug: Server returned 1 fewer activities for eager execution than we requested { + sdkComponent: 'core', + completion: 'WorkflowActivationCompletion(run_id: c1d2e101-d310-4fe3-9c43-964b98c8f1ba, status: Success(ScheduleActivity(1, greet) ))', + workflowId: 'workflow-8FKqZmi1_8F_Br4GH7RD6', + runId: 'c1d2e101-d310-4fe3-9c43-964b98c8f1ba', + taskQueue: 'custom-logger' +} +2025-01-27T20:40:39.014Z [workflow] debug: Marking WFT completed { + sdkComponent: 'core', + workflowId: 'workflow-8FKqZmi1_8F_Br4GH7RD6', + runId: 'c1d2e101-d310-4fe3-9c43-964b98c8f1ba', + completion: 'WorkflowActivationCompletion(run_id: c1d2e101-d310-4fe3-9c43-964b98c8f1ba, status: Success(ScheduleActivity(1, greet) ))', + taskQueue: 'custom-logger' +} +2025-01-27T20:40:39.017Z [activity] debug: Activity started { + sdkComponent: 'worker', + taskQueue: 'custom-logger', + isLocal: false, + attempt: 1, + namespace: 'default', + taskToken: 'CiQ0NmM0OWQ5Zi03ODQ4LTQwNjktYjMwZi01YjU2NTJmM2VjM2USHndvcmtmbG93LThGS3FabWkxXzhGX0JyNEdIN1JENhokYzFkMmUxMDEtZDMxMC00ZmUzLTljNDMtOTY0Yjk4YzhmMWJhIAUoATIBMUIFZ3JlZXRKCAgBELyAQBgB', + workflowId: 'workflow-8FKqZmi1_8F_Br4GH7RD6', + workflowRunId: 'c1d2e101-d310-4fe3-9c43-964b98c8f1ba', + workflowType: 'logSampleWorkflow', + activityId: '1', + activityType: 'greet' +} +2025-01-27T20:40:39.017Z [activity] info: Log from activity { + sdkComponent: 'activity', + taskQueue: 'custom-logger', + isLocal: false, + attempt: 1, + namespace: 'default', + taskToken: 'CiQ0NmM0OWQ5Zi03ODQ4LTQwNjktYjMwZi01YjU2NTJmM2VjM2USHndvcmtmbG93LThGS3FabWkxXzhGX0JyNEdIN1JENhokYzFkMmUxMDEtZDMxMC00ZmUzLTljNDMtOTY0Yjk4YzhmMWJhIAUoATIBMUIFZ3JlZXRKCAgBELyAQBgB', + workflowId: 'workflow-8FKqZmi1_8F_Br4GH7RD6', + workflowRunId: 'c1d2e101-d310-4fe3-9c43-964b98c8f1ba', + workflowType: 'logSampleWorkflow', + activityId: '1', + activityType: 'greet', + notfromsplat: 'not-from-splat', + extraObject: { errorInfo: 'This-is-the-error-info' } +} +2025-01-27T20:40:39.017Z [activity] debug: Activity completed { + sdkComponent: 'worker', + taskQueue: 'custom-logger', + isLocal: false, + attempt: 1, + namespace: 'default', + taskToken: 'CiQ0NmM0OWQ5Zi03ODQ4LTQwNjktYjMwZi01YjU2NTJmM2VjM2USHndvcmtmbG93LThGS3FabWkxXzhGX0JyNEdIN1JENhokYzFkMmUxMDEtZDMxMC00ZmUzLTljNDMtOTY0Yjk4YzhmMWJhIAUoATIBMUIFZ3JlZXRKCAgBELyAQBgB', + workflowId: 'workflow-8FKqZmi1_8F_Br4GH7RD6', + workflowRunId: 'c1d2e101-d310-4fe3-9c43-964b98c8f1ba', + workflowType: 'logSampleWorkflow', + activityId: '1', + activityType: 'greet', + durationMs: 0 +} +2025-01-27T20:40:39.020Z [worker] debug: New WFT { + sdkComponent: 'core', + action: 'NewWft(PermittedWft(PreparedWFT { task_token: TaskToken(CiQ0NmM0OWQ5Zi03ODQ4LTQwNjktYjMwZi01YjU2NTJmM2VjM2USHndvcmtmbG93LThGS3FabWkxXzhGX0JyNEdIN1JENhokYzFkMmUxMDEtZDMxMC00ZmUzLTljNDMtOTY0Yjk4YzhmMWJhIAgoAUoICAEQxoBAGAFQCWILCMfe37wGELjOpgk=), attempt: 1, execution: WorkflowExecution { workflow_id: "workflow-8FKqZmi1_8F_Br4GH7RD6", run_id: "c1d2e101-d310-4fe3-9c43-964b98c8f1ba" }, workflow_type: "logSampleWorkflow", legacy_query: None, query_requests: [], update: HistoryUpdate(previous_started_event_id: 3, started_id: 9, length: 6, first_event_id: Some(4)), messages: [] }))', + runId: 'c1d2e101-d310-4fe3-9c43-964b98c8f1ba' +} +2025-01-27T20:40:39.020Z [workflow] debug: Applying new workflow task from server { + sdkComponent: 'core', + messages: '[]', + hasLegacyQuery: 'false', + taskToken: 'CiQ0NmM0OWQ5Zi03ODQ4LTQwNjktYjMwZi01YjU2NTJmM2VjM2USHndvcmtmbG93LThGS3FabWkxXzhGX0JyNEdIN1JENhokYzFkMmUxMDEtZDMxMC00ZmUzLTljNDMtOTY0Yjk4YzhmMWJhIAgoAUoICAEQxoBAGAFQCWILCMfe37wGELjOpgk=', + runId: 'c1d2e101-d310-4fe3-9c43-964b98c8f1ba', + attempt: '1', + action: 'NewWft(PermittedWft(PreparedWFT { task_token: TaskToken(CiQ0NmM0OWQ5Zi03ODQ4LTQwNjktYjMwZi01YjU2NTJmM2VjM2USHndvcmtmbG93LThGS3FabWkxXzhGX0JyNEdIN1JENhokYzFkMmUxMDEtZDMxMC00ZmUzLTljNDMtOTY0Yjk4YzhmMWJhIAgoAUoICAEQxoBAGAFQCWILCMfe37wGELjOpgk=), attempt: 1, execution: WorkflowExecution { workflow_id: "workflow-8FKqZmi1_8F_Br4GH7RD6", run_id: "c1d2e101-d310-4fe3-9c43-964b98c8f1ba" }, workflow_type: "logSampleWorkflow", legacy_query: None, query_requests: [], update: HistoryUpdate(previous_started_event_id: 3, started_id: 9, length: 6, first_event_id: Some(4)), messages: [] }))', + update: 'HistoryUpdate(previous_started_event_id: 3, started_id: 9, length: 6, first_event_id: Some(4))', + workflowId: 'workflow-8FKqZmi1_8F_Br4GH7RD6' +} +2025-01-27T20:40:39.020Z [worker] debug: Sending activation to lang { + sdkComponent: 'core', + taskQueue: 'custom-logger', + activation: 'WorkflowActivation(run_id: c1d2e101-d310-4fe3-9c43-964b98c8f1ba, is_replaying: false, jobs: ResolveActivity(1, Completed))' +} +2025-01-27T20:40:39.022Z [workflow] info: Greeted { + sdkComponent: 'workflow', + taskQueue: 'custom-logger', + namespace: 'default', + workflowId: 'workflow-8FKqZmi1_8F_Br4GH7RD6', + runId: 'c1d2e101-d310-4fe3-9c43-964b98c8f1ba', + workflowType: 'logSampleWorkflow', + greeting: 'Hello, Temporal!' +} +2025-01-27T20:40:39.022Z [workflow] debug: Workflow completed { + sdkComponent: 'worker', + taskQueue: 'custom-logger', + namespace: 'default', + workflowId: 'workflow-8FKqZmi1_8F_Br4GH7RD6', + runId: 'c1d2e101-d310-4fe3-9c43-964b98c8f1ba', + workflowType: 'logSampleWorkflow' +} +2025-01-27T20:40:39.022Z [workflow] debug: wf bridge iteration fetch { + sdkComponent: 'core', + completion: 'WorkflowActivationCompletion(run_id: c1d2e101-d310-4fe3-9c43-964b98c8f1ba, status: Success(CompleteWorkflowExecution ))', + taskQueue: 'custom-logger', + runId: 'c1d2e101-d310-4fe3-9c43-964b98c8f1ba', + workflowId: 'workflow-8FKqZmi1_8F_Br4GH7RD6', + inCmds: '[CompleteWorkflowExecution]' +} +2025-01-27T20:40:39.022Z [workflow] debug: handling command { + sdkComponent: 'core', + completion: 'WorkflowActivationCompletion(run_id: c1d2e101-d310-4fe3-9c43-964b98c8f1ba, status: Success(CompleteWorkflowExecution ))', + state: 'CompleteWorkflowCommandCreated', + commandType: 'CompleteWorkflowExecution', + machineName: 'CompleteWorkflowMachine', + runId: 'c1d2e101-d310-4fe3-9c43-964b98c8f1ba', + workflowId: 'workflow-8FKqZmi1_8F_Br4GH7RD6', + taskQueue: 'custom-logger' +} +2025-01-27T20:40:39.022Z [workflow] debug: prepared commands { + sdkComponent: 'core', + completion: 'WorkflowActivationCompletion(run_id: c1d2e101-d310-4fe3-9c43-964b98c8f1ba, status: Success(CompleteWorkflowExecution ))', + runId: 'c1d2e101-d310-4fe3-9c43-964b98c8f1ba', + workflowId: 'workflow-8FKqZmi1_8F_Br4GH7RD6', + commands: '[Cmd&Machine(CompleteWorkflowExecution)]', + taskQueue: 'custom-logger' +} +2025-01-27T20:40:39.022Z [workflow] debug: Cancelling all local activities for run { + sdkComponent: 'core', + runId: 'c1d2e101-d310-4fe3-9c43-964b98c8f1ba', + taskQueue: 'custom-logger', + completion: 'WorkflowActivationCompletion(run_id: c1d2e101-d310-4fe3-9c43-964b98c8f1ba, status: Success(CompleteWorkflowExecution ))', + workflowId: 'workflow-8FKqZmi1_8F_Br4GH7RD6' +} +2025-01-27T20:40:39.022Z [workflow] debug: Sending responses to server { + sdkComponent: 'core', + forceNewWft: false, + runId: 'c1d2e101-d310-4fe3-9c43-964b98c8f1ba', + completion: 'WorkflowActivationCompletion(run_id: c1d2e101-d310-4fe3-9c43-964b98c8f1ba, status: Success(CompleteWorkflowExecution ))', + workflowId: 'workflow-8FKqZmi1_8F_Br4GH7RD6', + messages: '[]', + queryResponses: '[]', + taskQueue: 'custom-logger', + commands: '[CompleteWorkflowExecution]' +} +2025-01-27T20:40:39.023Z [workflow] debug: Marking WFT completed { + sdkComponent: 'core', + runId: 'c1d2e101-d310-4fe3-9c43-964b98c8f1ba', + taskQueue: 'custom-logger', + completion: 'WorkflowActivationCompletion(run_id: c1d2e101-d310-4fe3-9c43-964b98c8f1ba, status: Success(CompleteWorkflowExecution ))', + workflowId: 'workflow-8FKqZmi1_8F_Br4GH7RD6' +} \ No newline at end of file diff --git a/custom-logger/package.json b/custom-logger/package.json index cef9a2d6..b96bbf85 100644 --- a/custom-logger/package.json +++ b/custom-logger/package.json @@ -26,6 +26,7 @@ "@temporalio/client": "^1.11.6", "@temporalio/worker": "^1.11.6", "@temporalio/workflow": "^1.11.6", + "@temporalio/common": "^1.11.6", "nanoid": "3.x", "triple-beam": "^1.3.0", "winston": "^3.3.3" diff --git a/custom-logger/src/activities/index.ts b/custom-logger/src/activities/index.ts index e0e71b4c..19ce8431 100644 --- a/custom-logger/src/activities/index.ts +++ b/custom-logger/src/activities/index.ts @@ -1,8 +1,12 @@ import { log } from '@temporalio/activity'; +import { LogWrapper } from '../logWrapper'; + +const logger = new LogWrapper(log); // @@@SNIPSTART typescript-activity-use-injected-logger export async function greet(name: string): Promise { - log.info('Log from activity', { name }); + const errorFromCode = { errorInfo: 'This-is-the-error-info' }; + logger.info('Log from activity', errorFromCode,); return `Hello, ${name}!`; } // @@@SNIPEND diff --git a/custom-logger/src/logWrapper.ts b/custom-logger/src/logWrapper.ts new file mode 100644 index 00000000..883ba8b4 --- /dev/null +++ b/custom-logger/src/logWrapper.ts @@ -0,0 +1,40 @@ + +import { Logger } from '@temporalio/common'; +import { LogMetadata } from '@temporalio/worker'; + +/** + * Wrapper for the logger to allow an additional object or error to be passed to the logger. + * + * @example + * ```ts + * import { log } from '@temporalio/activity'; + * + * logger = LogWrapper(log); + * logger.info('Log from activity', { prop: 'value' }); + * ``` + */ +export class LogWrapper { + + private _logger: Logger; + + /** + * Create the logger by injecting a Activity logger. + * + * @param log the logger to be injected + */ + constructor(private logger: Logger) { + this._logger = logger; + } + + info(message: string, extraObject?: object, meta?: LogMetadata): void { + this._logger.info( + message, + extraObject + ? meta + ? { ...meta, fromsplat: "from-splat", extraObject: extraObject } + : { notfromsplat: "not-from-splat", extraObject: extraObject} + : meta + ); + } + +} \ No newline at end of file