implement LogTiming.Microtask, better test timings, breaking options API
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
import Logging, { LoggingConfiguration, LogTiming } from "@proxnet/undead-logging";
|
||||
|
||||
//LoggingConfiguration.logTiming = LogTiming.Deferred;
|
||||
|
||||
const log = new Logging("Main");
|
||||
log.i(`Deferred! - LogTiming.${LogTiming[log.logTiming]}`);
|
||||
|
||||
const timeout = setTimeout(() => { log.d(`Interval!`) }, 2000);
|
||||
|
||||
Deno.addSignalListener('SIGINT', () => {
|
||||
clearTimeout(timeout);
|
||||
|
||||
LoggingConfiguration.resetLogTiming = LogTiming.Sync;
|
||||
|
||||
log.i(`Sync! - LogTiming.${LogTiming[LoggingConfiguration.logTiming]}`);
|
||||
});
|
||||
25
tests/timing.ts
Normal file
25
tests/timing.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import Logging, {
|
||||
LoggingConfiguration,
|
||||
LogTiming,
|
||||
} from "../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 });
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user