Dist-Zilla-Plugin-LogContextual

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

        sub foo {
            log_debug {  }; # messes up and tries to call the log_debug method provided by $self->logger
        }

    There's an easy way around this, but it doesn't seem obvious at first
    glance.

        use Moose;
        use Log::Contextual::LogDispatchouli qw( log_debug );
        use namespace::autoclean;
        with 'Dist::Zilla::Role::Plugin';

        sub foo {
            log_debug {  }; # Now works
        }

    If you're confused, that is quite o.k.

    But its sensible once you understand how.

    Essentially, because the "log_debug" "sub" is removed at compile time,
    all calls to that become fixed, instead of flexible.

    So here's how "perl" processes the above code:

        # COMPILE PHASE
        use Moose;
        use Log::Contextual::LogDispatchouli qw( log_debug );
        use namespace::autoclean;

        sub foo {
            log_debug {  }; # BINDS this call to the imported sub
        }

        # END OF COMPILE PHASE
        # namespace::autoclean removes *log_debug forcing the bind
        # RUNTIME
        with  'Dist::Zilla::Role::Plugin'; # Cant change compile-time things.

    Its not 100% ideal, but it works!.

CAVEATS
    *   NO PREFIXES

        At this time, The nice pretty "[Foo/Bar]" prefix from
        "$plugin->plugin_name" is not supported.

        We're not sure if it ever will, it probably will, but the code makes
        my head hurt at present.

        Was better to release something, albeit feature incomplete, than to
        release nothing at all.

    *   REQUIRES "::LogDispatchouli" subclass

        This seems in contrast to the Log::Contextual design principles,
        things invoking loggers shouldn't care about how they're working,
        just they should work.

        I'm *Hoping* in a future release of "::LogDispatchouli" that it can
        transparently do the right thing when calling code simply does

            use Log::Contextual

        So the "Dispatchouli" is *strictly* top level knowledge.

        But I'll wait for updates on how that should work before I make it
        work that way =)

AUTHOR
    Kent Fredric <kentfredric@gmail.com>

COPYRIGHT AND LICENSE
    This software is copyright (c) 2013 by Kent Fredric
    <kentfredric@gmail.com>.

    This is free software; you can redistribute it and/or modify it under
    the same terms as the Perl 5 programming language system itself.



( run in 2.235 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )