Files
undead-logging/tests/timing.ts

25 lines
716 B
TypeScript

import Logging, {
LoggingConfiguration,
LogTiming,
} from "./../src/mod.ts";
LoggingConfiguration.logTiming = LogTiming.Microtask;
// high-priority logs
const log = new Logging("HTTP", { silent: false });
Deno.serve({ port: 8080, onListen: addr => {
log.n(`Listen information: ${JSON.stringify(addr)}`);
} }, async (req: Request) => {
const url = new URL(req.url);
if (url.pathname.includes('favicon.ico')) return new Response("Not Found", { status: 404 });
log.i("Received request:", url.pathname);
log.d("I/O start");
const res = await fetch("https://httpbin.org/delay/1");
log.d("I/O end");
return new Response(JSON.stringify(await res.json()), { status: 200 });
});