Skip to content

Commit 647731d

Browse files
feat: change console log driver signature, return log params
1 parent 5855bd3 commit 647731d

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

__tests__/drivers/console-log-test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ describe('drivers/console-log', () => {
7070

7171
ConsoleLog(custom)(getMessage, LogType.ERROR, 1);
7272

73-
expect(custom).calledOnceWith(LOG_ERROR_COLOR, sinon.match(message));
73+
expect(custom).calledOnceWith(sinon.match(message), {
74+
id: 1,
75+
type: LogType.ERROR,
76+
color: LOG_ERROR_COLOR,
77+
reqTime: '',
78+
});
7479
});
7580
});

src/drivers/console-log.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const ConsoleLog: ConsoleInfoType =
6161
if (log === undefined) {
6262
console.info(color, `${getMessage()} ${reqTime}`);
6363
} else if (log) {
64-
log(color, `${getMessage()} ${reqTime}`);
64+
log(`${getMessage()} ${reqTime}`, { id, type, color, reqTime });
6565
}
6666
};
6767

src/interfaces/drivers/console-log.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ enum LogType {
1515
*/
1616
type LogDriverType = (getMessage: () => string, type?: LogType, id?: number | string) => void;
1717

18-
type ConsoleInfoType = (log?: (color: string, message: string) => void) => LogDriverType;
18+
type ConsoleInfoType = (
19+
log?: (
20+
message: string,
21+
params: { type: LogType; color: string; reqTime: string; id?: number | string },
22+
) => void,
23+
) => LogDriverType;
1924

2025
export { LogDriverType, LogType, ConsoleInfoType };

0 commit comments

Comments
 (0)