Hi all (especially Andy :-) 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)
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. -N On 5 January 2017 at 09:30, Nathan Bailey <[email protected]> wrote: > Hi all, > For the archive/record, see below - all working now. I'd mis-indented the > yml config. > > cheers, > Nathan > > ---------- Forwarded message ---------- > Date: 4 January 2017 at 21:18 > Subject: Re: [dancer-users] Dancer2::Plugin::LogReport - basic setup > > > Nevermind, I see I indented the yml incorrectly: > logger: "LogReport" > > engines: > logger: > LogReport: > log_format: %a%i%m > app_name: AppName > dispatchers: > logfile: # "default" dispatcher stays open as well > type: FILE > to: /path/filename.log > charset: utf-8 > mode: DEBUG > > now works! > > And I see that adding the dispatcher line in a test harness lets me write > errors to a file rather than stderr too. > > Brilliant! > > thanks, > Nathan > > On 4 January 2017 at 19:51, Nathan Bailey <web@ <[email protected]>...> > wrote: > >> On 4 January 2017 at 19:12, Andrew Beverley <andy@ <[email protected]>...> >> wrote: >> >>> On Wed, 4 Jan 2017 Nathan Bailey wrote: >>> > 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). >>> >> >> They happily print to STDERR, they just don't print to the log file :-) >> >> I have: >> # The log level for this environment. Log warning and error messages* [ >> presumably this doesn't conflict with the LogReport log levels? ]* >> log: 'info' >> >> logger: "LogReport" >> >> engines: >> logger: >> LogReport: >> log_format: %a%i%m >> app_name: AppName >> dispatchers: >> logfile: # "default" dispatcher stays open as well >> type: FILE >> to: /path/filename.log >> charset: utf-8 >> mode: DEBUG >> >> >>> > 2. Add use Log::Report (); >>> >>> This is no longer needed (sorry, I thought the docs had been updated). >>> >> >> Okay, so I just have: >> use Dancer2; >> ... >> use Dancer2::Plugin::LogReport mode => 'DEBUG'; # '3' or 'DEBUG' >> >> in my main route handler module. >> >> With this config, nothing is being written to my log file (ie. normal >> 'info' messages that were getting written with: >> logger: "File" >> >> engines: >> logger: >> File: >> log_dir: "/path" >> file_name: "filename.log" >> (now removed and replaced with above) are no longer getting written. I >> have a 'trace' and 'info' in a non-Dancer module that is writing to stderr. >> >> 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. >>> >> >> Nifty! Presumably module-based unit tests need to include Log::Report >> with some suitable config/dispatcher? >> >> thanks, >> Nathan >> > > > > _______________________________________________ > dancer-users mailing list > [email protected] > http://lists.preshweb.co.uk/mailman/listinfo/dancer-users > >
_______________________________________________ dancer-users mailing list [email protected] http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
