[dancer-users] Converting from Dancer2::Logger::Syslog to Dancer2::Logger::LogReport

Andrew Beverley andy at andybev.com
Sun Feb 5 22:34:11 GMT 2017


On Sat, 4 Feb 2017 Clive Eisen <clive at hildebrand.co.uk> wrote:
> I’m sure I’m being extremely stupid here but I have tried to read the
> docs ;-)

Sorry, the docs are lacking in this area...

> using the former I get entries in syslog like
> 
> URL: /getHids in /usr/local/openresty/api/bin/../lib/api.pm l. 47
> 
> With the latter I get
> 
> URL: /getHids
> 
> I assume I need to tweak the log_format

This is a bit of an oversight on my part, and the documentation does
not explain it.

An older version of Logger::LogReport *did* include a call to Dancer2's
format_message function, which would have meant things working for you
as expected. However, I took that out, as:

1. There was inconsistency, as only messages generated within Dancer
were being formatted (not messages generated directly from Log::Report)

2. I assumed that any formatting of logs would be done via the
applicable dispatcher, such as [1]. Unfortunately, information on line
numbers is not available within the formatter, but having had a quick
look at the source code I think it would be easy to add. Watch this
space.

I should probably ask: what do you want to achieve and how are you
instigating the logging at the moment? There might be some better
solutions. For example, if you combine with Log::Report and/or
Dancer2::Plugin::LogReport, then you could call "assert" for your
logging, and that automatically includes the line number (although
another release will be needed shortly to fix the location of the
correct line from the stack trace).

Andy

[1] https://metacpan.org/pod/Log::Report::Dispatcher::Syslog#format-=%3E-CODE


More information about the dancer-users mailing list