mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2026-07-02 22:24:59 +08:00
18 lines
477 B
TypeScript
18 lines
477 B
TypeScript
import process from 'node:process';
|
|
|
|
import { consola } from 'consola';
|
|
|
|
export function setupGlobalConsole(opts: { dev?: boolean } = {}) {
|
|
// Wrap all console logs with consola for better DX
|
|
if (opts.dev) {
|
|
consola.wrapAll();
|
|
}
|
|
else {
|
|
consola.wrapConsole();
|
|
}
|
|
|
|
process.on('unhandledRejection', err => consola.error('[unhandledRejection]', err));
|
|
|
|
process.on('uncaughtException', err => consola.error('[uncaughtException]', err));
|
|
}
|