From: Jim C. <jc...@di...> - 2003-08-11 21:18:55
|
somebody else was asking that a validation be done on new configs, discarding them if theyre broken. I thought this was a good idea, so started down that path. This is a preliminary version, without the actual validation. Its NOT FOR CHECKIN But it does compare new version of $data (from read_confg()) against old, and reports whether theres a meaningful change. a number of issues remain: IIUC, The actual CONFIG thats used to make logging decisions is stored in various package globals, making it difficult to cleanly store a current and backup config. It feels a bit hackish, but is probably easiest, to copy the package globals to globals_bak variables. Im using Data::Compare for the new vs old, and it cant compare CODErefs. so it wont work on coderefs in the config. This limitation could be avoided by doing the comparison before the sub{} text is eval'd into coderefs. Doing so however interferes with next item. The new vs old check should probably be much higher in the body of _init(), nominally immediately after call to read_config(). I tried this, but found that the comparison always reported differences. I believe its due to structural changes made on $data during LOADING into the config. (IE deleting keys whose value is an empty hash. Because the structure is shared with $ref_config_read_data, code was effectively comparing massaged vs unmassaged data. the patch to Config.pm uses a custom version of Data::Compare, which includes diffs(), a routine which trims out common elements of 2 structures, leaving only the differences. Its not yet ready for prime-time, but Im hoping to eventually get it accepted into Data::Compare |