<div dir="ltr">Hi all,<div> For the archive/record, see below - all working now. I'd mis-indented the yml config.</div><div><br></div><div>cheers,</div><div>Nathan</div><div><br><div class="gmail_quote">---------- Forwarded message ----------<br>Date: 4 January 2017 at 21:18<br>Subject: Re: [dancer-users] Dancer2::Plugin::LogReport - basic setup<br><br><br><div dir="ltr">Nevermind, I see I indented the yml incorrectly:<div><span class=""><div>logger: "LogReport"</div><div><br></div><div>engines:</div><div> logger:</div><div> LogReport:</div><div> log_format: %a%i%m</div><div> app_name: AppName</div><div> dispatchers:</div><div> logfile: # "default" dispatcher stays open as well</div><div> type: FILE</div><div> to: /path/filename.log</div><div> charset: utf-8</div><div> mode: DEBUG</div><div><br></div></span><div>now works!</div><div><br></div><div>And I see that adding the dispatcher line in a test harness lets me write errors to a file rather than stderr too.</div><div><br></div><div>Brilliant!</div><div><br></div><div>thanks,</div><div>Nathan </div><div><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On 4 January 2017 at 19:51, Nathan Bailey <span dir="ltr"><<a href="mailto:web@polynate.net" target="_blank">web@</a>...></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="m_1158538149351023948m_-7180579705848793965gmail-">On 4 January 2017 at 19:12, Andrew Beverley <span dir="ltr"><<a href="mailto:andy@andybev.com" target="_blank">andy@</a>...></span> wrote:<br></span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="m_1158538149351023948m_-7180579705848793965gmail-m_7267054915294232457gmail-"><span class="m_1158538149351023948m_-7180579705848793965gmail-">On Wed, 4 Jan 2017 Nathan Bailey wrote:<br></span><span class="m_1158538149351023948m_-7180579705848793965gmail-">> 1. Add logging information to my yml<br>
<br>
</span></span><span class="m_1158538149351023948m_-7180579705848793965gmail-">Yes, although if you just want to test it initially, then you don't<br>
need any config and any messages will go to STDERR (I think).<br></span></blockquote><div><br></div><div>They happily print to STDERR, they just don't print to the log file :-)</div><div><br></div><div>I have:</div><div># The log level for this environment. Log warning and error messages<i> [ presumably this doesn't conflict with the LogReport log levels? ]</i></div><div>log: 'info'</div><div><br></div><div>logger: "LogReport"</div><div><br></div><div>engines:</div><div> logger:</div><div> LogReport:</div><div> log_format: %a%i%m</div><div> app_name: AppName</div><div> dispatchers:</div><div> logfile: # "default" dispatcher stays open as well</div><div> type: FILE</div><div> to: /path/filename.log</div><div> charset: utf-8</div><div> mode: DEBUG</div><span class="m_1158538149351023948m_-7180579705848793965gmail-"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="m_1158538149351023948m_-7180579705848793965gmail-m_7267054915294232457gmail-">
> 2. Add use Log::Report ();<br>
<br>
</span>This is no longer needed (sorry, I thought the docs had been updated).<br></blockquote><div><br></div></span><div>Okay, so I just have:</div><div>use Dancer2;</div><div>...</div><div>use Dancer2::Plugin::LogReport mode => 'DEBUG'; # '3' or 'DEBUG'<br></div><div><br></div><div>in my main route handler module.</div><div><br></div><div>With this config, nothing is being written to my log file (ie. normal 'info' messages that were getting written with:</div><div><div>logger: "File"</div><div> </div><div>engines:</div><div> logger:</div><div> File:</div><div> log_dir: "/path"</div><div> file_name: "filename.log"</div></div><div>(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.</div><span class="m_1158538149351023948m_-7180579705848793965gmail-"><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Log::Report maintains some global space that all messages go to. When a<br>
message is logged (regardless of where it is logged from) that will<br>
trigger the logging code in the Dancer plugin. The Dancer plugin knows<br>
your config, so it all Just Works.<br></blockquote><div><br></div></span><div>Nifty! Presumably module-based unit tests need to include Log::Report with some suitable config/dispatcher?</div><div><br></div><div>thanks,</div><div>Nathan </div></div></div></div>
</blockquote></div><br></div></div></div></div></div>
</div><br></div></div>