Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

Commit

Permalink
chore: add logs (#2740)
Browse files Browse the repository at this point in the history
  • Loading branch information
crowlKats authored Apr 5, 2023
1 parent 05cc85a commit 65e34d8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
17 changes: 16 additions & 1 deletion routes/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export default function API(
}

export const handler: Handlers<LibDocPage> = {
async GET(req, { params, render }) {
async GET(req, { params, render, remoteAddr }) {
const url = new URL(req.url);

if (!params.version) {
Expand All @@ -154,7 +154,22 @@ export const handler: Handlers<LibDocPage> = {
resURL.searchParams.set("symbol", symbol);
}

const id = crypto.randomUUID();
console.log(
`req_id=${id} req_url=${url} req_ip=${
(remoteAddr as Deno.NetAddr).hostname
} apiland_url=${resURL}`,
);
const time = performance.now();

const res = await fetch(resURL);

console.log(
`req_id=${id} apiland_duration=${
performance.now() - time
} apiland_status=${res.status}`,
);

if (res.status === 504) {
console.error("/api Timed out");
}
Expand Down
14 changes: 14 additions & 0 deletions routes/x/module.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,24 @@ export const handler: Handlers<PageData> = {

let data: Data;

const id = crypto.randomUUID();
console.log(
`req_id=${id} req_url=${url} req_ip=${
(remoteAddr as Deno.NetAddr).hostname
} apiland_url=${resURL}`,
);
const time = performance.now();

const res = await fetch(resURL, {
redirect: "manual",
});

console.log(
`req_id=${id} apiland_duration=${
performance.now() - time
} apiland_status=${res.status}`,
);

if (res.status === 504) {
console.error(`/x/${name} Timed out`);
}
Expand Down

0 comments on commit 65e34d8

Please sign in to comment.