mirror of
https://github.com/Seldaek/monolog.git
synced 2026-04-26 08:05:53 +03:00
[GH-ISSUE #321] Remove inline line breaks from line formatter #108
Labels
No labels
Bug
Documentation
Feature
Needs Work
Support
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/monolog#108
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @gunnarlium on GitHub (Feb 14, 2014).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/321
I'm a bit unsure about the best approach for a problem I'm having, and wanted to hear some opionions before making a PR.
When the LineFormatter is used to log exceptions, and the message of the thrown exception has line breaks, the line breaks are inlcuded in the Monolog message, in effect causing the log message to span multiple lines. This breaks many log parsers, as they expected each entry to span exactly one line. I would rather want these line breaks to replaced be replaced by either
\nor. I can quite easily create a SingleLineFormatter that extends the LineFormatter:So I guess my question is whether it would make sense to make something like this the default behavior of the line formatter, whether such a forced single line formatter might be relevant for inclusion in Monolog, or if I should just create it myself whenever I need it?
@Seldaek commented on GitHub (Feb 14, 2014):
I think this can be considered a bugfix, the line formatter really shouldn't produce multiple lines output unless you put line breaks in the format yourself. It could probably be optional in case someone really wants to keep the old behavior so if you want to send a PR with a constructor flag that'd be great.
@gunnarlium commented on GitHub (Feb 14, 2014):
Created a pull request. I'm "readding" a trailing line break if the message has a trailing line break.
When this is enabled, having custom inline line breaks in the format won't work. So if we want to allow such line breaks, but not linebreaks in the actual message, we need to something more complex, I think.