Improved logging on settings storage.

This commit is contained in:
kkapsner 2018-07-12 01:18:49 +02:00
parent 88b5e7668f
commit 6dc08534a6
1 changed files with 16 additions and 2 deletions

View File

@ -139,17 +139,25 @@
return true;
};
const storeValue = function storeValue(newValue){
logging.verbose("Trying to store new value for %s", name, newValue);
settings[name] = newValue;
if (!settingDefinition.transient){
var storeObject = {};
storeObject[name] = newValue;
browser.storage.local.set(storeObject);
browser.storage.local.set(storeObject).then(function(){
logging.verbose("New value stored for %s:", name, newValue);
}, function(err){
logging.warning("Unable to store new value for %s:", name, newValue, err);
});
}
else {
logging.warning("Transient setting %s cannot be stored.", name);
}
};
if (settingDefinition.urlSpecific){
return function setValue(newValue, url){
logging.verbose("New value for %s:", name, newValue);
logging.verbose("New value for %s (%s):", name, url, newValue);
if (isValid(newValue)){
if (url){
var urlContainerValue = urlContainer.get();
@ -169,6 +177,9 @@
storeValue(newValue);
}
}
else{
logging.warning("Invalid value for %s (%s):", name, url, newValue);
}
};
}
else {
@ -177,6 +188,9 @@
if (isValid(newValue)){
storeValue(newValue);
}
else{
logging.warning("Invalid value for %s:", name, newValue);
}
};
}
}