12 lines
359 B
TypeScript
12 lines
359 B
TypeScript
import { debug, info } from "./log.ts";
|
|
import { DateTime } from "luxon";
|
|
|
|
export type Task = () => Promise<void>;
|
|
|
|
export const wrapTask = (name: string, task: Task) => async () => {
|
|
debug("Running task", { name });
|
|
const start = DateTime.now();
|
|
await task();
|
|
info("Task finished", { name, time: `${-start.diffNow("milliseconds")} ms` });
|
|
};
|