Dancer2::Plugin::LogReport - basic setup
Hi all, I'm endeavouring to use Dancer2::Plugin::LogReport so that all our errors go to one log file. As I understand the documentation (POD in Dancer2::Plugin::LogReport), I need to: 1. Add logging information to my yml 2. Add use Log::Report (); and use Dancer2::Plugin::LogReport mode => DEBUG; to my main route handler module 3. use Log::Report; in my modules Presumably, however, I need to tell the modules about my Log::Report configuration. Does this mean I need a: dispatcher 'FILE', 'log', mode => 'DEBUG', to => '/path/mylogfile.log'; in every method/subroutine? I assume not, but I can't see how the non-Dancer2 modules are getting the config information since they are ignorant of the .yml file. thanks, Nathan
On Wed, 4 Jan 2017 Nathan Bailey wrote:
I'm endeavouring to use Dancer2::Plugin::LogReport so that all our errors go to one log file.
As I understand the documentation (POD in Dancer2::Plugin::LogReport), I need to: 1. Add logging information to my yml
Yes, although if you just want to test it initially, then you don't need any config and any messages will go to STDERR (I think). To send Dancer internal logs to Log::Report, you just need logger: "LogReport" in your config. To add a dispatcher to send the messages elsewhere, you also need engines: logger: LogReport: ... As per the docs.
2. Add use Log::Report ();
This is no longer needed (sorry, I thought the docs had been updated).
and use Dancer2::Plugin::LogReport mode => DEBUG; to my main route handler module 3. use Log::Report; in my modules
Correct.
Presumably, however, I need to tell the modules about my Log::Report configuration. Does this mean I need a: dispatcher 'FILE', 'log', mode => 'DEBUG', to => '/path/mylogfile.log';
in every method/subroutine?
No, all you need in your modules is: use Log::Report;
I assume not, but I can't see how the non-Dancer2 modules are getting the config information since they are ignorant of the .yml file.
Log::Report maintains some global space that all messages go to. When a message is logged (regardless of where it is logged from) that will trigger the logging code in the Dancer plugin. The Dancer plugin knows your config, so it all Just Works. Are you having problems which means that is not happening? Andy
participants (2)
-
Andrew Beverley -
Nathan Bailey