diff --git a/src/index.ts b/src/index.ts index 813856f..944eb3e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -17,16 +17,6 @@ if (envIsProd()) { console.log = console.warn = console.error = console.info = console.debug = () => { /* disable in favor of logger */ }; } -// At your app’s entry point -process.on('uncaughtException', (err) => { - console.error('Uncaught exception caught:', err); - // Decide: exit gracefully or continue -}); - -process.on('unhandledRejection', (reason) => { - console.error('Unhandled rejection:', reason); -}); - const logger = winston.createLogger({ transports: [ new winston.transports.Console({ @@ -38,6 +28,14 @@ const logger = winston.createLogger({ ], }); +process.on('uncaughtException', (error) => { + logger.error('Uncaught exception caught:', error); +}); + +process.on('unhandledRejection', (reason) => { + logger.error('Unhandled rejection: ', reason); +}); + if (process.env['ALL_PROXY']) { const proxyUrl = new URL(process.env['ALL_PROXY']); if (proxyUrl.protocol === 'socks5:') {