From: Anno S. <ann...@ma...> - 2008-10-03 10:19:30
|
I'd like to add the ability to give multiple (partial) configuration files to init() and init_and_watch(). In place of a single file, you could specify an array(ref) of files, whose concatenation is used in initialization, and which are all watched for changes. A user might say init_and_watch([ 'my_std_root.conf', # almost everything might use that 'my_application.conf', # special to this application 'that_module.conf', # came with That::Module, which i'm using ], 'HUP'); to invoke a few components. Editing or replacing any of them would be noticed by the application (after a HUP). I believe that such a feature would help in managing configuration files. The appended patch adds the feature to Log4perl, in a yet somewhat sketchy way. I'd like to hear opinions whether this would be a useful addition and if it has a chance of being accepted. If I'm on the wrong trip and everything speaks for monolithic configuration files, please say so. Here are some technicalities about the patch, of interest if you intend to try this at home :) It's against v 1.18 from CPAN and can be applied from inside a fresh build dir as "patch -p0 <log4perl_combo.patch". It addds, under lib/, the module Log/Log4perl/Config/Combo.pm, and it modifies .../Config.pm and .../Watch.pm to understand the additional form of file specification. "prove -Ilib t/" should show that the changes are compatible with the current behavior. To see the new behavior, unpack demo.tgz in the build dir (won't work anywhere else) and cd into demo. Inspect "runme", then run it as "perl runme", in case the shebang doesn't work. runme configures l4p from the two files root.conf and one.conf and then produces sample log events on demand. It takes an optional argument, the time or signal to pass to init_and_watch(). The idea is to use another shell to edit and/or replace the configuration files, then see if the changes are honored. The directory reset_conf contains the original configuration files again. Regards, Anno |