Logging Update

- Changed to uniform logging with the 'debug' module
- Updated all apps
This commit is contained in:
Logan Cusano
2022-12-11 21:11:29 -05:00
parent e403560165
commit e5d885cc3e
21 changed files with 105 additions and 53 deletions

View File

@@ -1,5 +1,6 @@
// Debug
const debug = require('debug')('client:updatePresets');
const { DebugBuilder } = require("../utilities/debugBuilder.js");
const log = new DebugBuilder("client", "updatePresets");
// Modules
const fs = require('fs');
@@ -12,7 +13,7 @@ function writePresets(presets, callback = undefined) {
fs.writeFile("../config/radioPresets.json", JSON.stringify(presets), (err) => {
// Error checking
if (err) throw err;
debug("Write Complete");
log.DEBUG("Write Complete");
if (callback) callback()
});
}
@@ -29,7 +30,7 @@ function sanitizeFrequencies(frequenciesArray) {
sanitizedFrequencyArray.push(convertFrequencyToHertz(freq));
}
debug(sanitizedFrequencyArray);
log.DEBUG("Sanitized Frequency Array", sanitizedFrequencyArray);
return sanitizedFrequencyArray;
}
@@ -42,12 +43,12 @@ function convertFrequencyToHertz(frequency){
// check if the passed value is a number
if(typeof frequency == 'number' && !isNaN(frequency)){
if (Number.isInteger(frequency)) {
debug(`${frequency} is integer.`);
log.DEBUG(`${frequency} is an integer.`);
// Check to see if the frequency has the correct length
if (frequency.toString().length >= 7 && frequency.toString().length <= 9) return frequency
}
else {
debug(`${frequency} is a float value.`);
log.DEBUG(`${frequency} is a float value.`);
// Convert to a string to remove the decimal in place and then correct the length
frequency = frequency.toString();
// One extra digit checked for the '.' included in the string
@@ -63,7 +64,7 @@ function convertFrequencyToHertz(frequency){
}
}
} else {
debug(`${frequency} is not a number`);
log.DEBUG(`${frequency} is not a number`);
frequency = convertFrequencyToHertz(parseFloat(frequency));
return parseInt(frequency)