Skip to content

Commit

Permalink
fix: error log formatting for fancy preset
Browse files Browse the repository at this point in the history
  • Loading branch information
cybercoder-naj committed Mar 21, 2024
1 parent a18261e commit ac7a2a9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/presets/fancy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@ const getDateTimeString = (date: Date) => {
const hours = date.getHours();
const minutes = date.getMinutes();
const seconds = date.getSeconds();
return chalk.gray(`${day}/${month}/${year} ${hours}:${minutes}:${seconds}`);
return `${day}/${month}/${year} ${hours}:${minutes}:${seconds}`;
};

const preset: PresetValue = {
uses: ['time', 'method', 'path'],
formatAttr: {
onSuccess({ time, method, path }) {
const dateTime = getDateTimeString(time!!);
const dateTime = chalk.gray(getDateTimeString(time!!));
const methodPath = chalk.cyan(`${method} ${path}`);

return `${dateTime} ${methodPath}`;
},
onFailure() {
return '';
onFailure({ request, datetime }) {
const dateTime = getDateTimeString(datetime!!);
return chalk.red(`${dateTime} ${request.method} ${request.url}`);
}
}
};
Expand Down

0 comments on commit ac7a2a9

Please sign in to comment.