[dancer-users] RESOLUTION: Dancer2::Plugin::LogReport - basic setup
Nathan Bailey
web at polynate.net
Wed Jan 4 22:30:16 GMT 2017
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@ <web at polynate.net>...>
wrote:
> On 4 January 2017 at 19:12, Andrew Beverley <andy@ <andy at andybev.com>...>
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20170105/4ba1c319/attachment.html>
More information about the dancer-users
mailing list