fix(core, messaging, websockets): formatted logs for undefined values
MODIFY
packages/core/src/logger/logger.interface.ts
packages/core/src/logger/logger.interface.ts
@@ -15,5 +15,6 @@ export const enum LoggerTag {
CORE = 'core',
HTTP = 'http',
MESSAGING = 'messaging',
+ EVENT_BUS = 'event_bus',
WEBSOCKETS = 'websockets',
};

MODIFY
packages/messaging/src/middlewares/messaging.eventLogger.middleware.ts
packages/messaging/src/middlewares/messaging.eventLogger.middleware.ts
@@ -10,7 +10,8 @@ export const inputLogger$: MsgMiddlewareEffect = (event$, ctx) => {
return event$.pipe(
tap(event => {
const tag = transportLayer.config.channel;
- const message = `${event.type}, id: ${event.metadata?.correlationId}`;
+ const id = event.metadata?.correlationId;
+ const message = id ? `${event.type}, id: ${id}` : event.type;
logger({
tag,
@@ -33,8 +34,10 @@ export const outputLogger$: MsgOutputEffect = (event$, ctx) => {
const message = error
? `"${error.name}", "${error.message}" for event ${type}`
: metadata?.replyTo
- ? `${event.type}, id: ${metadata?.correlationId ?? '-'} and sent to ${metadata?.replyTo ?? '-'}`
- : `${event.type}, id: ${metadata?.correlationId ?? '-'}`;
+ ? `${event.type}, id: ${metadata?.correlationId || '-'} and sent to "${metadata.replyTo || '-'}"`
+ : metadata?.correlationId
+ ? `${event.type}, id: ${metadata.correlationId}`
+ : event.type
logger({
tag,
@@ -53,7 +56,7 @@ export const errorLogger$: MsgMiddlewareEffect = (event$, ctx) => {
return event$.pipe(
tap(event => {
- const message = `"${event.error?.name ?? '-'}: ${event.error?.message ?? '-' }" for event ${event.type}`;
+ const message = `"${event.error?.name || '-'}: ${event.error?.message || '-' }" for event ${event.type}`;
return logger({
tag,

MODIFY
packages/websockets/src/middlewares/websockets.eventLogger.middleware.ts
packages/websockets/src/middlewares/websockets.eventLogger.middleware.ts
@@ -7,7 +7,8 @@ export const inputLogger$: WsMiddlewareEffect = (event$, ctx) => {
return event$.pipe(
tap(event => {
- const message = `${event.type}, id: ${event.metadata?.correlationId}`;
+ const id = event.metadata?.correlationId;
+ const message = id ? `${event.type}, id: ${id}` : event.type;
logger({
message,
@@ -28,8 +29,10 @@ export const outputLogger$: WsMiddlewareEffect = (event$, ctx) => {
const message = error
? `"${error.name}", "${error.message}" for event ${type}`
: metadata?.replyTo
- ? `${event.type}, id: ${metadata?.correlationId ?? '-'} and sent to ${metadata?.replyTo ?? '-'}`
- : `${event.type}, id: ${metadata?.correlationId ?? '-'}`;
+ ? `${event.type}, id: ${metadata?.correlationId || '-'} and sent to "${metadata.replyTo || '-'}"`
+ : metadata?.correlationId
+ ? `${event.type}, id: ${metadata.correlationId}`
+ : event.type;
logger({
message,
@@ -46,7 +49,7 @@ export const errorLogger$: WsMiddlewareEffect = (event$, ctx) => {
return event$.pipe(
tap(event => {
- const message = `"${event.error?.name ?? '-'}: ${event.error?.message ?? '-' }" for event ${event.type}`;
+ const message = `"${event.error?.name || '-'}: ${event.error?.message || '-' }" for event ${event.type}`;
return logger({
message,

fix(core, messaging, websockets): formatted logs for undefined values