Skip to content
This repository has been archived by the owner on May 1, 2020. It is now read-only.

Commit

Permalink
fix(serve): allow multiple arguments in console.log
Browse files Browse the repository at this point in the history
  • Loading branch information
imhoffd committed Aug 15, 2017
1 parent 8e64407 commit 5c00970
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/dev-server/notification-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});

Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 5c00970

Please sign in to comment.