Skip to content

Commit

Permalink
apply feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Jul 19, 2024
1 parent 093b5ee commit be104be
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .changeset/blue-jars-hang.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ Enhances the dev server logging when rewrites occur during the lifecycle or rend
The dev server will log the status code **before** and **after** a rewrite:

```shell
08:16:48 [404rewrite → 200] /foo/about 200ms
08:22:13 [200rewrite → 404] /about 23ms
08:16:48 [404] (rewrite) /foo/about 200ms
08:22:13 [200] (rewrite) /about 23ms
```
13 changes: 4 additions & 9 deletions packages/astro/src/core/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,19 @@ export function req({
method,
statusCode,
reqTime,
formerStatusCode,
isRewrite,
}: {
url: string;
statusCode: number;
method?: string;
reqTime?: number;
formerStatusCode?: number;
isRewrite?: boolean;
}): string {
const color = statusCode >= 500 ? red : statusCode >= 300 ? yellow : blue;
let statusCodeLabel;
if (formerStatusCode) {
statusCodeLabel = color(`[${formerStatusCode} → rewrite → ${statusCode}]`);
} else {
statusCodeLabel = color(`[${statusCode}]`);
}
return (
statusCodeLabel +
color(`[${statusCode}]`) +
` ` +
`${isRewrite ? color('(rewrite) ') : ''}` +
(method && method !== 'GET' ? color(method) + ' ' : '') +
url +
` ` +
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/vite-plugin-astro-server/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export async function handleRoute({
url: pathname,
method: incomingRequest.method,
statusCode: isRewrite ? response.status : (status ?? response.status),
formerStatusCode: isRewrite ? status : undefined,
isRewrite,
reqTime: timeEnd - timeStart,
})
);
Expand Down

0 comments on commit be104be

Please sign in to comment.