From: Jim C. <jc...@di...> - 2003-10-24 23:22:26
|
Mike Schilli wrote: >Jim Cromie wrote on 10/23/2003, 5:41 AM: > > > But its not my usage per se, its a recommendation to users who > > would use AutoCategorize on some modules and not others. > > > > Telling them to use Log::Log4perl::Config->_init() > > *does* just work however, and I can live with that. > >Not sure I understand why one would need to 'add' configuration parts >instead of a complete reset&load. Feeding parts to the configuration >which are highly dependent on previously fed parts sounds error-prone to >me. What's the rationale? > > > The idea was to improve coexistence of both approaches in a larger application. It would seem possible that a project would have; * an EasyUser.pm, which would use :easy logging and easy_init(), * a StandardUser.pm, which would use the more explicit API * an AutoCatUser.pm, which uses my module my test: t/09_coexist_easy.t uses 1,3 together in the same executable, and they 'share' a single config, which contains whatever easy_init() put there, and my config, slapped in with it. That test now uses this code snippet, ie l4p::Config::_init, to avoid resetting easy_init()s config-initializations. use Log::Log4perl::AutoCategorize ( alias => 'myLogger', initfile => 'log-conf', # no effect here ); use Log::Log4perl qw(:easy); myLogger->easy_init ({ level => $INFO, file => "out.09_coexist_easy_easyout", layout => 'F=%F{1} M=%M L=%L: Cat=%c %m%n', }); # add initialization wo resetting Log::Log4perl::Config->_init('log-conf'); Im perfectly happy with this solution - and it implicitly flags the situation as less than ideal. As a project gets larger, they probably want to switch from Easy to Standard anyway - but Im not above luring them in with seductive appeal of Laziness :-D I agree that it would be easy to construct problematic configs this way, trashing earlier config by respesifying those items, and probably hard to debug. I will be adding some caveats to that effect in my upcoming 0.03 release. BTW - it was your feedback wrt interoperation/coexistence that started this ;-) thx again for a very cool module. |