On Wed, Apr 29, 2009 at 04:03:12PM -0400, Michael_Schilli via RT wrote:
Show quoted text> <URL:
https://rt.cpan.org/Ticket/Display.html?id=45559 >
>
> > Yes, where the log message ends with a newline but you want extra
> > information, like %M, %F etc etc, to be added after the
> > message instead of before.
>
> Problem is we need to balance different needs for different users. This
> feature came about because noobs were using
>
> use Log::Log4perl qw(:easy);
> Log::Log4perl->easy_init($DEBUG);
> DEBUG "waah!\n";
>
> and were wondering why they were getting two newlines. (What goes on
> behind the scenes is that "%m%n" is used as a layout). In hindsight,
> that probably wasn't the smartest decision, but I guess people got used
> to it, and we can't take it away easily.
>
> Here's my take: using a newline in a log message isn't recommended if
> you don't want it to be taken literally.
(I see a vague parallel with the terminator vs separator issue with
commas and semicolons.)
Show quoted text> Chomping the message in "%m%n" while leaving it unchomped in other cases
> caters the noobs, but leaves open the possibility that an experienced
> user actually meant to add a newline.
I think experienced users are also likely to want to add information
after the message.
Show quoted text> Wouldn't it be easier to get rid of the newlines in the log messages
> instead?
Umm. I believe log4j assumes log messages don't end with a newline.
On the other hand, Log::Dispatch takes the view that they should
http://search.cpan.org/~drolsky/Log-Dispatch/lib/Log/Dispatch.pm#Why_doesn't_Log::Dispatch_add_a_newline_to_the_message?
[Curiously, the examples on the main Log::Dispatch page don't contain a
newline, but the example on the Log::Dispatch::File does! That goes
against the principle of keeping the act of logging by the application
separate from where the messages end up.]
I couldn't find any discussion of this issue in the docs.
Also, the examples in the docs are inconsistent in their use of
newlines. Some do, some don't. That should be fixed.
So some users, especially on large teams, might find themselves with
some code using trailing newlines and some not.
Two suggestions:
1. Add a config option to control chomping: true, false, or undef, where
undef is the current (undocumented) /%m%n/ mechanism.
2. Add a placeholder that means "message but chomped", perhaps %m{chomp}.
Neither would change existing behaviour by default, and both provide
a solution to the issue.
Tim.