From cb679039472e51ff795d729d69f1906de0d96c86 Mon Sep 17 00:00:00 2001 From: Markus Tacker Date: Wed, 24 Jul 2019 12:17:12 +0200 Subject: [PATCH] fix(device-simulator): improve logging --- scripts/connect.ts | 13 +++---------- scripts/device/ui-server.ts | 1 - 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/scripts/connect.ts b/scripts/connect.ts index 836e0237..acb61084 100644 --- a/scripts/connect.ts +++ b/scripts/connect.ts @@ -74,7 +74,7 @@ const main = async (args: { deviceId: string }) => { deviceUiUrl, deviceId: clientId, onUpdate: update => { - console.log({ clientId, state: { state: { reported: update } } }) + console.log(chalk.magenta('<'), chalk.cyan(JSON.stringify(update))) connection.update(clientId, { state: { reported: update } }) }, }) @@ -88,15 +88,8 @@ const main = async (args: { deviceId: string }) => { console.log(chalk.magenta('reconnecting...')) }) - connection.on('status', function(thingName, stat, _, stateObject) { - console.log( - 'received ' + - stat + - ' on ' + - thingName + - ': ' + - JSON.stringify(stateObject), - ) + connection.on('status', (_, stat) => { + console.log(chalk.magenta('>'), chalk.cyan(stat)) }) connection.on('delta', function(thingName, stateObject) { diff --git a/scripts/device/ui-server.ts b/scripts/device/ui-server.ts index 5f98b14f..f3564989 100644 --- a/scripts/device/ui-server.ts +++ b/scripts/device/ui-server.ts @@ -35,7 +35,6 @@ export const uiServer = async (args: { }) request.on('end', () => { try { - console.log(body) const update = JSON.parse(body) args.onUpdate(update) response.writeHead(202, {