mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2026-03-25 00:00:14 +08:00
Replace fs-extra/rimraf with native node:fs, lodash with structuredClone/spread, ts-node with tsx, minimist with node:util parseArgs, winston with console logger, async-promise-queue with native Promise concurrency. Use promisify for child_process.exec. Normalize all imports to use node: protocol. Extract Jest config to jest.config.ts and replace ts-jest with @swc/jest.
31 lines
777 B
TypeScript
31 lines
777 B
TypeScript
const profiles = new Map<string, number>();
|
|
|
|
export const Logger = {
|
|
error(...args: unknown[]) {
|
|
console.error('[error]', ...args);
|
|
},
|
|
info(...args: unknown[]) {
|
|
console.info('[info]', ...args);
|
|
},
|
|
verbose(...args: unknown[]) {
|
|
console.log('[verbose]', ...args);
|
|
},
|
|
debug(...args: unknown[]) {
|
|
console.debug('[debug]', ...args);
|
|
},
|
|
silly(...args: unknown[]) {
|
|
console.debug('[silly]', ...args);
|
|
},
|
|
profile(label: string) {
|
|
const now = performance.now();
|
|
const start = profiles.get(label);
|
|
if (start !== undefined) {
|
|
const durationMs = Math.round(now - start);
|
|
console.info(`[info] ${label} {"durationMs":${durationMs}}`);
|
|
profiles.delete(label);
|
|
} else {
|
|
profiles.set(label, now);
|
|
}
|
|
},
|
|
};
|