lib/debug.js
function writeToLogFile(rawPacket, parsedPacket) {
  if (!debugMode) { return; }

  var now = new Date().toUTCString();

  fs.appendFile(config.debugRawDataFile, 'Package received at ' + now + ':\n' + rawPacket + '\n\n', function (err) {
    if (err) {
      console.error('Could not write raw package to ' + config.debugRawDataFile);
    }
  });

  fs.appendFile(config.debugParsedDataFile, 'Package received at ' + now + ':\n' + JSON.stringify(parsedPacket, true, 4) + '\n\n', function (err) {
    if (err) {
      console.error('Could not write parsed package to ' + config.debugParsedDataFile);
    }
  });
}
function writeToLogFile(rawPacket, parsedPacket) {
  if (!debugMode) { return; }

  var now = new Date().toUTCString();

  fs.appendFile(config.debugRawDataFile, 'Package received at ' + now + ':\n' + rawPacket + '\n\n', function (err) {
    if (err) {
      console.error('Could not write raw package to ' + config.debugRawDataFile);
    }
  });

  fs.appendFile(config.debugParsedDataFile, 'Package received at ' + now + ':\n' + JSON.stringify(parsedPacket, true, 4) + '\n\n', function (err) {
    if (err) {
      console.error('Could not write parsed package to ' + config.debugParsedDataFile);
    }
  });
}
function writeToLogFile ( rawPacket , parsedPacket ) { if ( ! debugMode ) { return ; } var now = new Date ( ) . toUTCString ( ) ; fs . appendFile ( config . debugRawDataFile , 'Package received at ' + now + ':\n' + rawPacket + '\n\n' , function ( err ) { if ( err ) { console . error ( 'Could not write raw package to ' + config . debugRawDataFile ) ; } } ) ; fs . appendFile ( config . debugParsedDataFile , 'Package received at ' + now + ':\n' + JSON . stringify ( parsedPacket , true , 4 ) + '\n\n' , function ( err ) { if ( err ) { console . error ( 'Could not write parsed package to ' + config . debugParsedDataFile ) ; } } ) ; }
Write raw and parsed data to log file for debugging purposes

@param rawPacket : Raw packet as received via the serial port
@param parsedPacket : Parsed packet object
Write raw and parsed data to log file for debugging purposes