Converting from Dancer2::Logger::Syslog to Dancer2::Logger::LogReport
Hi I’m sure I’m being extremely stupid here but I have tried to read the docs ;-) 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 I have tried this (only reference I could find to the format string is in Log4perl) LogReport: log_format: '%a%i%m in %F at %L' But it continues to just display as before - not even with the ‘in’ or the ‘at’ as indeed does commenting it out - so I assume %a%i%m is a default Are the log_format string options defined anywhere? What have I missed? TIA config I am using logger: LogReport: log_format: '%a%i%m in %F at %L' app_name: api dispatchers: default: type: SYSLOG identity: api facility: local0 flags: "pid ndelay nowait" mode: DEBUG logsocket: host: 172.16.101.16 port: 10010 type: udp — Clive Eisen
On Sat, 4 Feb 2017 Clive Eisen <clive@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
On Sun, 5 Feb 2017 Andrew Beverley <andy@andybev.com> wrote:
On Sat, 4 Feb 2017 Clive Eisen <clive@hildebrand.co.uk> wrote:
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.
Thinking about this more, maybe there should be a configuration option to enable/disable for Dancer formatter, so that you can use Dancer2::Logger::LogReport as a drop-in replacement to Dancer2::Logger::Syslog. Would that help? Andy
On 6 Feb 2017, at 08:01, Andrew Beverley <andy@andybev.com> wrote:
Thinking about this more, maybe there should be a configuration option to enable/disable for Dancer formatter, so that you can use Dancer2::Logger::LogReport as a drop-in replacement to Dancer2::Logger::Syslog. Would that help?
That would be perfect - basically Dancer2::Logger::Syslog no longer passes it’s build test with ‘newer perls’. I belive this has been reported to you. So a plugin replacement - oh yes please
Andy
— Clive
On Mon, 6 Feb 2017 Clive Eisen <clive@hildebrand.co.uk> wrote:
On 6 Feb 2017, at 08:01, Andrew Beverley <andy@andybev.com> wrote: That would be perfect - basically Dancer2::Logger::Syslog no longer passes it’s build test with ‘newer perls’. I belive this has been reported to you.
Yes, sorry, and syspete has even done me a patch...
So a plugin replacement - oh yes please
No problem, I will aim to look at both of these today. Incidentally, you do gain a whole bunch of functionality with ::LogReport over ::Syslog. I created the former after finding the latter quite limited. Do shout if you have any general logging questions, and I'll see if I can come up with some use-cases (it's always more interesting looking at practical examples, instead of "here's a list of things you can do"). Andy
On Mon, 6 Feb 2017 Clive Eisen <clive@hildebrand.co.uk> wrote:
So a plugin replacement - oh yes please
Sorry for the delay. I've got a copy working locally now - it will hopefully be on CPAN later today. The new version checks whether Dancer2::Plugin::LogReport has been loaded, and if not it formats like a normal logger. Andy
On Mon, 6 Feb 2017 Clive Eisen <clive@hildebrand.co.uk> wrote:
So a plugin replacement - oh yes please
Log::Report v1.19 released to CPAN, which will encompass the changes discussed: now, if the LogReport plugin is not loaded, then the LogReport logger will behave and format like a normal logger (although there will be additional stacktrace information depending on the level and source of the error). Many thanks for the feedback, and to Mark Overmeer for making the release - I am just piggy-backing off his module! Andy
participants (2)
-
Andrew Beverley -
Clive Eisen