Improved logging again
This commit is contained in:
parent
8c61879bb4
commit
3d14c7a60a
@ -2,32 +2,30 @@
|
||||
const gpio = require('../custom_modules/VoidGPIO.js');
|
||||
const config = require('../custom_modules/config.json');
|
||||
const fn = require('../custom_modules/functions.js');
|
||||
const { State } = require('../custom_modules/HestiaClasses.js');
|
||||
|
||||
// Variables
|
||||
process.pinMap = new Map();
|
||||
|
||||
fn.log('Initializing pinMap');
|
||||
fn.log('Initializing pinMap', 'DEBUG');
|
||||
for (const pin of config.pins) {
|
||||
process.pinMap.set(pin.key, pin);
|
||||
}
|
||||
|
||||
// Initialize state
|
||||
fn.log('Initializing state');
|
||||
process.psState = new State(config);
|
||||
|
||||
// Auger Loop
|
||||
fn.log('Starting auger loop');
|
||||
setInterval(fn.routines.cycleAuger, 2000);
|
||||
fn.log('Starting auger loop', 'DEBUG');
|
||||
setInterval(() => {
|
||||
fn.log('Running auger', 'DEBUG');
|
||||
gpio.setPin(process.pinMap.get('auger').board, 1);
|
||||
setTimeout(() => {
|
||||
gpio.setPin(process.pinMap.get('auger').board, 0);
|
||||
}, process.env.AUGER_CYCLE_TIME || 500);
|
||||
}, 2000);
|
||||
|
||||
fn.log('Setting exhaust to low to keep NC relay closed and fan running');
|
||||
fn.log('Setting exhaust to low to keep NC relay closed and fan running', 'DEBUG');
|
||||
gpio.setPin(process.pinMap.get('exhaust').board, 0);
|
||||
|
||||
fn.log('Enabling auger');
|
||||
process.psState.auger.on = true;
|
||||
|
||||
process.on('SIGINT', () => {
|
||||
fn.log(`Exiting gracefully...`);
|
||||
fn.log(`Exiting gracefully...`, 'INFO');
|
||||
gpio.setPin(process.pinMap.get('auger').board, 0);
|
||||
process.exit();
|
||||
});
|
@ -10,9 +10,24 @@ for (const pin of pins) {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
log(message) {
|
||||
if (debug) {
|
||||
console.log(message);
|
||||
log(message, level) {
|
||||
if (level) {
|
||||
switch (level) {
|
||||
case 'INFO':
|
||||
console.log(`INFO: ${message}`);
|
||||
break;
|
||||
case 'DEBUG':
|
||||
if (debug) {
|
||||
console.log(`DEBUG: ${message}`);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (debug) {
|
||||
console.log(`DEBUG: ${message}`);
|
||||
}
|
||||
}
|
||||
},
|
||||
sleep(ms) {
|
||||
|
Loading…
Reference in New Issue
Block a user