Simplify debugging runtime config object changes

This commit is contained in:
KernelDeimos 2024-05-23 18:40:41 -04:00
parent c89b50bf31
commit 5042d49935

View File

@ -175,9 +175,25 @@ const config_pointer = {};
// We'd like to store values changed at runtime separately
// for easier runtime debugging
{
const config_runtime_values = {};
const config_runtime_values = {
$: 'runtime-values'
};
config_runtime_values.__proto__ = config_to_export;
config_to_export = config_runtime_values
// These can be difficult to find and cause painful
// confusing issues, so we log any time this happens
config_to_export = new Proxy(config_to_export, {
set: (target, prop, value, receiver) => {
console.log(
'\x1B[36;1mCONFIGURATION MUTATED AT RUNTIME\x1B[0m',
prop, 'to', value
);
// console.log(new Error('stack trace to find configuration mutation'));
target[prop] = value;
return true;
}
})
}
module.exports = config_to_export;
module.exports = config_to_export;