From 5c00970b0e4ab457d745738afb91425976e6b6fb Mon Sep 17 00:00:00 2001 From: Daniel Imhoff Date: Tue, 15 Aug 2017 18:36:57 -0500 Subject: [PATCH] fix(serve): allow multiple arguments in console.log fixes https://github.com/ionic-team/ionic-cli/issues/2243 --- src/dev-server/notification-server.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/dev-server/notification-server.ts b/src/dev-server/notification-server.ts index 44c4f555..7aab19a7 100644 --- a/src/dev-server/notification-server.ts +++ b/src/dev-server/notification-server.ts @@ -79,12 +79,13 @@ export function createNotificationServer(config: ServeConfig) { // we've successfully connected wsServer = ws; - wsServer.on('message', (incomingMessage: string) => { + wsServer.on('message', (incomingMessage: any) => { // incoming message from the client try { printMessageFromClient(JSON.parse(incomingMessage)); } catch (e) { Logger.error(`error opening ws message: ${incomingMessage}`); + Logger.error(e.stack ? e.stack : e); } }); @@ -112,22 +113,23 @@ export function createNotificationServer(config: ServeConfig) { function printConsole(msg: WsMessage) { const args = msg.data; args[0] = `console.${msg.type}: ${args[0]}`; + const log = args.join(' '); switch (msg.type) { case 'error': - Logger.error.apply(this, args); + Logger.error(log); break; case 'warn': - Logger.warn.apply(this, args); + Logger.warn(log); break; case 'debug': - Logger.debug.apply(this, args); + Logger.debug(log); break; default: - Logger.info.apply(this, args); + Logger.info(log); break; } }