diff --git a/packages/metro/src/lib/TerminalReporter.js b/packages/metro/src/lib/TerminalReporter.js index 49d1512ac..398ad87ef 100644 --- a/packages/metro/src/lib/TerminalReporter.js +++ b/packages/metro/src/lib/TerminalReporter.js @@ -41,8 +41,18 @@ export type TerminalReportableEvent = ... } | { - type: 'unstable_set_interaction_status', - status: ?string, + type: 'unstable_server_log', + level: 'info' | 'warn' | 'error', + data: string | Array, + ... + } + | { + type: 'unstable_server_menu_updated', + message: string, + ... + } + | { + type: 'unstable_server_menu_cleared', ... }; @@ -251,6 +261,15 @@ class TerminalReporter { case 'client_log': logToConsole(this.terminal, event.level, event.mode, ...event.data); break; + case 'unstable_server_log': + const logFn = { + info: reporting.logInfo, + warn: reporting.logWarning, + error: reporting.logError, + }[event.level]; + const [format, ...args] = [].concat(event.data); + logFn(this.terminal, String(format), ...args); + break; case 'dep_graph_loading': const color = event.hasReducedPerformance ? chalk.red : chalk.blue; const version = 'v' + require('../../package.json').version; @@ -385,8 +404,11 @@ class TerminalReporter { case 'bundle_transform_progressed_throttled': this._updateBundleProgress(event); break; - case 'unstable_set_interaction_status': - this._interactionStatus = event.status; + case 'unstable_server_menu_updated': + this._interactionStatus = event.message; + break; + case 'unstable_server_menu_cleared': + this._interactionStatus = null; break; } } diff --git a/packages/metro/src/lib/reporting.js b/packages/metro/src/lib/reporting.js index 7087762e4..1a84acfb0 100644 --- a/packages/metro/src/lib/reporting.js +++ b/packages/metro/src/lib/reporting.js @@ -211,6 +211,18 @@ function logError( ); } +/** + * Similar to `logWarning`, but for informational messages. + */ +function logInfo( + terminal: Terminal, + format: string, + ...args: Array +): void { + const str = util.format(format, ...args); + terminal.log('%s: %s', chalk.cyan('info'), str); +} + /** * A reporter that does nothing. Errors and warnings will be swallowed, that * is generally not what you want. @@ -220,5 +232,6 @@ const nullReporter = {update(): void {}}; module.exports = { logWarning, logError, + logInfo, nullReporter, };