Skip to content

Commit

Permalink
feat: add logLevel to the event payload when available
Browse files Browse the repository at this point in the history
  • Loading branch information
Yehonal committed Nov 13, 2024
1 parent 8df32ce commit fe62970
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions event-manager/src/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export interface IEventPayload {
data?: IDataInfo;
eventName: string;
config?: any;
level?: LogLevel;
/**
* This is used to log the error information.
* NOTE: eventName and config are redundant here.
Expand Down Expand Up @@ -253,6 +254,7 @@ export function event<
*
* We build the logger function here unless the logger is false
*/
let logLevel: LogLevel | undefined = undefined;
if (logger !== false) {
const {
instance: _instance,
Expand All @@ -268,6 +270,8 @@ export function event<
...rest,
};

logLevel = level;

const message = optionalMessage ?? formattedEventName;

const logData = errorPayload ? errorPayload : { data };
Expand Down Expand Up @@ -305,6 +309,7 @@ export function event<
data,
eventName: formattedEventName,
config,
level: logLevel,
errorInfo: !_.isEmpty(errorPayload) ? errorPayload : undefined,
};

Expand Down

0 comments on commit fe62970

Please sign in to comment.