[dancer-users] Updating to the new Dancer2 plugin system

Amelia Ireland aireland at lbl.gov
Thu Jan 12 22:17:27 GMT 2017


Hello Dancers,

What's the recommended procedure for converting a plugin that may import an
unspecified number of keywords into the app? I use
Dancer2::Plugin::LogContextual
<https://github.com/wchristian/Dancer2-Plugin-LogContextual>, which imports
a set of keywords via use Log::Contextual ':log' and redefines
$SIG{__WARN__} for the application by adding an around method modifier to
to_app. I'm unsure of the best way to handle this with the new plugin
system (I am not the plugin author).

A sample of the plugin code:

around to_app => sub {
    my ( $attr, $self, @args ) = @_;
    my $app = $self->$attr( @args );
    return sub {
        local $SIG{__WARN__} = sub {
            my @args = @_;
            log_warn { @args };
        };
        return $app->( @_ );
    };
};



Any hints gratefully received. Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20170112/aa0adcad/attachment.html>


More information about the dancer-users mailing list