package Mojolicious::Plugin::LogReport;
use Mojo::Base 'Mojolicious::Plugin';

use Log::Report;

my @messages;

sub register
{   my ($self, $app, $conf) = @_;

    $app->helper('lr_messages' => \&lr_messages);

    sub cb($$$)
    {   my ($disp, $options, $reason, $message) = @_;
        push @messages, $message;
    }

    dispatcher CALLBACK => 'cb'
       , callback => \&cb;
}

sub lr_messages
{   my @copy = @messages;
    @messages = ();
    return @copy;
}

1;
