From 252e6401bfff24196446aea154804d37e1dbab0a Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Mon, 23 May 2016 15:03:50 -0700 Subject: [PATCH] use a local logfile for mqtt * When running locally, use ./mqtt.log instead of ../logs/mqtt.log * This quells an error and provides local testing * Also update .gitignore --- .gitignore | 2 ++ app.js | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index c311e8f..828a4cc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ launchConfigurations/ local-* /node_modules +/npm-debug.log +/mqtt.log diff --git a/app.js b/app.js index 7bb5a38..f08c88a 100644 --- a/app.js +++ b/app.js @@ -81,8 +81,8 @@ mqttServe.on('clientConnected', function(client) { mqttServe.on('published', function(packet, client){ console.log('Message: ', packet.payload.toString("utf8")); - - fs.appendFile("../logs/mqtt.log", packet.topic + ": " + packet.payload.toString("utf8") + "\n", function(err) { + var logfile = appEnv.isLocal ? "mqtt.log" : "../logs/mqtt.log"; + fs.appendFile(logfile, packet.topic + ": " + packet.payload.toString("utf8") + "\n", function(err) { if(err) { return console.log(err); }