Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize call normalizeRecord if necessary #1906

Merged
merged 6 commits into from
Nov 11, 2024
Merged

Conversation

johndodev
Copy link
Contributor

@johndodev johndodev commented Aug 11, 2024

Monolog version 3

Hello,

When you format a logRecord with JsonFormater::format(), it calls:

  • NormalizeFormatter::format()
  • NormalizeFormatter::normalizeRecord()

As a result, we get a nicely formatted record, including any exception data, if present.

However, when we try to format an array of records using JsonFormater::formatBatch() :

  • JsonFormater::formatBatchJson()
  • JsonFormater::normalize()

We lose the exception data.

As I understand, formatBatch is a way to format array of records in an optimized way if possible, with the output being the same as formatting each record individually in a foreach.

If this is the case, it may be a bug, and this PR fixes it for me.
I don't know if this issue affects anything other than exception data, but it was this specific case that led me to discover the problem.
For more context, I was writing a custom Handler, where I call this->getFormatter()->formatBatch($records); in handleBatch().

@Seldaek Seldaek merged commit 5d5da57 into Seldaek:main Nov 11, 2024
16 of 18 checks passed
@johndodev johndodev deleted the patch-1 branch November 11, 2024 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants