Skip to content

Commit 287d697

Browse files
fix: default setup for fancy
1 parent bc9c702 commit 287d697

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

bun.lockb

0 Bytes
Binary file not shown.

src/presets/fancy.ts

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,25 @@ const getDateTimeString = (date: Date) => {
1212
return `${day}/${month}/${year} ${hours}:${minutes}:${seconds}`;
1313
};
1414

15+
const defaultOptions: LogesticOptions = {
16+
showLevel: true
17+
};
18+
1519
export default (options: LogesticOptions) =>
16-
new Logestic(options).use(['time', 'method', 'path']).format({
17-
onSuccess({ time, method, path }) {
18-
const dateTime = chalk.gray(getDateTimeString(time!!));
19-
const methodPath = chalk.cyan(`${method} ${path}`);
20+
new Logestic({
21+
...defaultOptions,
22+
...options
23+
})
24+
.use(['time', 'method', 'path'])
25+
.format({
26+
onSuccess({ time, method, path }) {
27+
const dateTime = chalk.gray(getDateTimeString(time!!));
28+
const methodPath = chalk.cyan(`${method} ${path}`);
2029

21-
return `${dateTime} ${methodPath}`;
22-
},
23-
onFailure({ request, datetime }) {
24-
const dateTime = getDateTimeString(datetime!!);
25-
return chalk.red(`${dateTime} ${request.method} ${request.url}`);
26-
}
27-
});
30+
return `${dateTime} ${methodPath}`;
31+
},
32+
onFailure({ request, datetime }) {
33+
const dateTime = getDateTimeString(datetime!!);
34+
return chalk.red(`${dateTime} ${request.method} ${request.url}`);
35+
}
36+
});

0 commit comments

Comments
 (0)