[dancer-users] RESOLUTION: Dancer2::Plugin::LogReport - basic setup

Andrew Beverley andy at andybev.com
Thu Jan 5 07:20:53 GMT 2017


On Thu, 5 Jan 2017 Nathan Bailey wrote:
> Hi all (especially Andy :-)

Hi Nathan :)

> What are you supposed to put in your non-main route handlers?
> use Dancer2::Plugin::LogReport mode => 'DEBUG'; (like main route
> handler); OR
> use Log::Report; (like other modules)

It depends if you want to use the "special" Dancer-specific keywords
(such as process and success). If you don't, I would just use
Log::Report;

> I assume the later, however in all cases (with none or either of the
> above), I had an error that Log::Report wouldn't report, ie. I had to
> change my environment.yml back to logger: "File" to see it. It was a
> missing dependency - I'd started using a function that I hadn't use'd
> the module for.
> 
> 'File' wrote:
> [AppName::Module:PID] error @2017-01-05 14:47:42> Route exception:
> Undefined subroutine &Mod::Mod::sub called at path/file.pm line 254.
> in /Library/Perl/5.18/Dancer2/Core/App.pm l. 1441
> 
> in the log files, but 'LogReport' wrote nothing.

I have to admit that I'd never tried using the module in such a way.
I've just tried now, and I see what you mean. A very quick debug shows
Dancer calling the Log::Report plugin (as it should) but with different
parameters than it does for the main route handler. Strangely it seems
to be passing details of a 404 error for the page that generates the
exception. I don't have time to look at it right now; I'll make some
time later, but if you want to have a look yourself in the meantime,
then the key part of the plugin is in Plugin/LogReport.pm in $dsl->hook
(init_error ... just after on_plugin_import;

Andy


More information about the dancer-users mailing list