(server)
| 17 | name: 'vite:forward-console', |
| 18 | apply: 'serve', |
| 19 | configureServer(server) { |
| 20 | for (const name of pluginOpts.environments) { |
| 21 | const environment = server.environments[name] |
| 22 | environment.hot.on('vite:forward-console', (payload) => { |
| 23 | if ( |
| 24 | payload.type === 'error' || |
| 25 | payload.type === 'unhandled-rejection' |
| 26 | ) { |
| 27 | const output = formatError(payload, environment, sourceMapCache) |
| 28 | environment.config.logger.error(output, { |
| 29 | timestamp: true, |
| 30 | }) |
| 31 | } else { |
| 32 | const output = |
| 33 | c.dim(`[console.${payload.data.level}] `) + payload.data.message |
| 34 | if (payload.data.level === 'error') { |
| 35 | environment.config.logger.error(output, { |
| 36 | timestamp: true, |
| 37 | }) |
| 38 | } else if (payload.data.level === 'warn') { |
| 39 | environment.config.logger.warn(output, { |
| 40 | timestamp: true, |
| 41 | }) |
| 42 | } else { |
| 43 | environment.config.logger.info(output, { |
| 44 | timestamp: true, |
| 45 | }) |
| 46 | } |
| 47 | } |
| 48 | }) |
| 49 | } |
| 50 | }, |
| 51 | } |
| 52 | } |
| 53 |
nothing calls this directly
no test coverage detected