Skip to content

Commit

Permalink
reduce warn messages if error occurs to 1 per message
Browse files Browse the repository at this point in the history
  • Loading branch information
DutchmanNL committed Apr 17, 2020
1 parent c6fc1b3 commit 03d352e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const stateAttr = require('./lib/stateAttr.js');
const { wait } = require('./lib/tools');
const countryJs = require('country-list-js');
const allCountrys = []; // Array for all countrys to store in object
const warnMessages = {};
// For Germany, arrays to store federal states, city and counties to store in object
let allGermanyFederalStates = [], allGermanCountyDetails = [], allGermanyCounties = [], allGermanyCities = [];
let allGermanyFederalStatesLoaded = null, allGermanyCountiesLoaded = null, allGermanyCitiesLoaded = null;
Expand Down Expand Up @@ -490,7 +491,11 @@ class Covid19 extends utils.Adapter {
try {
// Try to get details from state lib, if not use defaults. throw warning if states is not known in attribute list
if (stateAttr[name] === undefined) {
this.log.warn(`State attribute definition missing for + ${name}`);
const warnMessage = `State attribute definition missing for + ${name}`;
if (warnMessages[name] !== warnMessage) {
warnMessages[name] = warnMessage;
this.log.warn(`State attribute definition missing for + ${name}`);
}
}
const writable = stateAttr[name] !== undefined ? stateAttr[name].write || false : false;
const state_name = stateAttr[name] !== undefined ? stateAttr[name].name || name : name;
Expand Down

0 comments on commit 03d352e

Please sign in to comment.