-
Notifications
You must be signed in to change notification settings - Fork 7
Improved message logging #385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
2b4cfc1
c60d2b1
da8a606
eeb03d4
cead1ef
c8c8be8
6dabe52
03b7220
6ec3e15
f45eaee
3f995f8
901a5ed
bcb2775
e8642b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,8 +55,6 @@ export type Prehandler<MessagePayloadSchema extends object, ExecutionContext, Pr | |
| next: (result: PrehandlerResult) => void, | ||
| ) => void | ||
|
|
||
| export const defaultLogFormatter = <MessagePayloadSchema>(message: MessagePayloadSchema) => message | ||
|
|
||
| export type HandlerConfigOptions< | ||
| MessagePayloadSchema extends object, | ||
| ExecutionContext, | ||
|
|
@@ -98,7 +96,7 @@ export class MessageHandlerConfig< | |
| PrehandlerOutput, | ||
| BarrierOutput | ||
| > | ||
| public readonly messageLogFormatter: LogFormatter<MessagePayloadSchema> | ||
| public readonly messageLogFormatter?: LogFormatter<MessagePayloadSchema> | ||
| public readonly preHandlerBarrier?: BarrierCallback< | ||
| MessagePayloadSchema, | ||
| ExecutionContext, | ||
|
|
@@ -126,7 +124,7 @@ export class MessageHandlerConfig< | |
| this.definition = eventDefinition | ||
| this.messageType = options?.messageType | ||
| this.handler = handler | ||
| this.messageLogFormatter = options?.messageLogFormatter ?? defaultLogFormatter | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why remove default formatter? if not set, we prefer not logging at all?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are still always logging message metadata, and if custom formatter is provided, we are additionally including formatted message there. If it's not provided, we are skipping this additional property |
||
| this.messageLogFormatter = options?.messageLogFormatter | ||
| this.preHandlerBarrier = options?.preHandlerBarrier | ||
| this.preHandlers = options?.preHandlers ?? [] | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -106,20 +106,6 @@ describe('MessageHandlerConfigBuilder', () => { | |
| expect(config.messageLogFormatter).toBe(messageLogFormatter) | ||
| expect(config.preHandlers).toEqual([]) | ||
| }) | ||
|
|
||
| it('should use default log formatter when not provided', () => { | ||
| const handler = () => Promise.resolve({ result: 'success' as const }) | ||
|
|
||
| const config = new MessageHandlerConfig(USER_MESSAGE_SCHEMA, handler) | ||
|
|
||
| const testMessage: UserMessage = { | ||
| type: 'user.created', | ||
| userId: '123', | ||
| email: '[email protected]', | ||
| } | ||
|
|
||
| expect(config.messageLogFormatter(testMessage)).toEqual(testMessage) | ||
| }) | ||
| }) | ||
| }) | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.