Skip to content

Commit

Permalink
use a local logfile for mqtt
Browse files Browse the repository at this point in the history
* When running locally, use ./mqtt.log instead of ../logs/mqtt.log
* This quells an error and provides local testing
* Also update .gitignore
  • Loading branch information
srl295 committed May 23, 2016
1 parent 31370cf commit 252e640
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
launchConfigurations/
local-*
/node_modules
/npm-debug.log
/mqtt.log
4 changes: 2 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 252e640

Please sign in to comment.