metaperl has asked for the wisdom of the Perl Monks concerning the following question:

MooseX::Log::Log4perl is a role. However, the role will not work with Log::Log4Perl being initialized. If moose roles could be subclassed, then you would simply create a local subclass of MooseX::Log::Log4perl and do your Log::Log4perl initiation there. But that is not possible. So somehow you need to do your local initialization and then also use this role, which seems a bit non-encapsulated.



The mantra of every experienced web application developer is the same: thou shalt separate business logic from display. Ironically, almost all template engines allow violation of this separation principle, which is the very impetus for HTML template engine development.

-- Terence Parr, "Enforcing Strict Model View Separation in Template Engines"

  • Comment on How would you extend MooseX::Log::Log4perl?

Replies are listed 'Best First'.
Re: How would you extend MooseX::Log::Log4perl?
by spazm (Monk) on Jul 11, 2011 at 22:12 UTC
    I see what you're saying. The docs for MooseX::Log::Log4perl show a required BEGIN block to initialize Log::Log4perl.
    package MyApp; use Moose; use Log::Log4perl qw(:easy); with 'MooseX::Log::Log4perl'; BEGIN { Log::Log4perl->easy_init(); }
    Should one initialize Log::Log4perl and add the BEGIN block both in the application base class?