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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

johndodev
Copy link

@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().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants