-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Conversation
JFYI, the login of our application broke because of this change (the 2FA process writes some logs, triggering the issue) : we have a custom JsonFormatter that had the following code : public function normalizeRecord(LogRecord $record): array
{
$normalized = parent::normalizeRecord($record);
if (isset($normalized['context']['exception'])) {
$normalized = /* ... */;
}
return $normalized;
} Except now
Thought you should know. Maybe this should be considered a BC break, and users should be alerted more explicitly ? |
I mean this is really a string of bad luck.. every change is a possible BC break given the right circumstances. I know it sucks when it hits you though. |
True, though I don't think we're the only one to have a custom JsonNormalizer to add more contextual info to the logs (or process it slightly differently). Seems to me like a very common use case for a logging library, that's why I'm afraid others will be hit too. Maybe just editing the release on github to add a warning / link to this conversation might do the trick, or a sentence like :
|
Yeah this was always the case tho from format()'s perspective, only normalizeRecord now possibly returns objects too. I'll add a note but I am not sure how common this really is.. It is pretty nasty tho that isset would throw like that. I thought it was more forgiving. |
Monolog version 3
Hello,
When you format a logRecord with JsonFormater::format(), it calls:
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() :
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);
inhandleBatch()
.