Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

Commit

Permalink
Better log colors and enabled debug by default
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando committed Jan 30, 2019
1 parent a75e280 commit 20592b0
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Fully configurable Zwave to MQTT **Gateway** and **Control Panel**.
cd Zwave2Mqtt
wget https://github.com/robertsLando/Zwave2Mqtt/files/2811961/zwave2mqtt-v1.0.0.zip
unzip zwave2mqtt-v1.0.0.zip
DEBUG=z2m:* ./zwave2mqtt
./zwave2mqtt
```

2. If you want to compile last code from github:
Expand All @@ -60,7 +60,7 @@ Fully configurable Zwave to MQTT **Gateway** and **Control Panel**.
npm run build
npm start
```

- Open the browser http://localhost:8091

## Development :nerd_face:
Expand Down
3 changes: 3 additions & 0 deletions bin/www
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
debug = require('debug')('z2m:App'),
conf = reqlib('/config/app.js');

//Enable debug by default
require('debug').enable('z2m:*');

// jsonstore is a singleton instance that handles the json configuration files
// used in the application. Init it before anything else than start app.
// if jsonstore fails exit the application
Expand Down
4 changes: 3 additions & 1 deletion lib/Gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ var reqlib = require('app-root-path').require,
debug = require('debug')('z2m:Gateway'),
inherits = require('util').inherits;

debug.color = 2;

const NODE_PREFIX = "nodeID_";
const GW_TYPES = ["valueID", "named", "manual"];
const PY_TYPES = ["time_value", "zwave_value", "just_value"];
Expand Down Expand Up @@ -47,7 +49,7 @@ function init(config, zwave, mqtt){
zwave.on('scanComplete', onScanComplete.bind(this));
zwave.connect();
}else{
debug("Gateway need both MQTT and Zwave Configuration to work")
debug("Gateway needs both MQTT and Zwave Configuration to work")
}

}
Expand Down
2 changes: 2 additions & 0 deletions lib/MqttClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ var reqlib = require('app-root-path').require,
debug = require('debug')('z2m:Mqtt'),
inherits = require('util').inherits;

debug.color = 5;

const CLIENTS_PREFIX = '_CLIENTS';
const DEVICES_PREFIX = '$devices';

Expand Down
2 changes: 2 additions & 0 deletions lib/ZwaveClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ store = reqlib('config/store.js'),
debug = require('debug')('z2m:Zwave'),
inherits = require('util').inherits;

debug.color = 4;

//Events to subscribe to
const EVENTS = {
'driver ready': driverReady,
Expand Down
4 changes: 3 additions & 1 deletion lib/jsonStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ var jsonfile = require('jsonfile'),
reqlib = require('app-root-path').require,
storeDir = reqlib('config/app.js').storeDir,
Promise = require('bluebird'),
debug = require('debug')('z2m:Store'),
utils = reqlib('lib/utils.js');

debug.color = 3;

function getFile(config){
return new Promise((resolve, reject) => {
Expand All @@ -14,7 +16,7 @@ function getFile(config){
reject(err);
}else{
if(err && err.code == 'ENOENT')
console.log(config.file, "not found");
debug(config.file, "not found");

resolve({file: config.file, data: data || config.default})
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
},
"scripts": {
"dev": "webpack-dev-server --inline --progress --host 0.0.0.0 --config build/webpack.dev.conf.js",
"dev:server": "DEBUG=z2m:* nodemon bin/www",
"start": "DEBUG=z2m:* node bin/www",
"dev:server": "nodemon bin/www",
"start": "node bin/www",
"lint": "eslint --ext .js,.vue src",
"build": "node build/build.js",
"pkg": "sudo chmod +x package.sh && ./package.sh"
Expand Down

0 comments on commit 20592b0

Please sign in to comment.