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

Updating the logging code to not throw away all class information #1493

Merged
merged 2 commits into from
Feb 10, 2021

Conversation

ryanrath
Copy link
Contributor

@ryanrath ryanrath commented Feb 8, 2021

Description

We ran into a problem described in this PR: #1490 After some research I found that the
root of the problem is this function json_encode'ing $record when the contents
of $record may contain objects that do not support JsonSerializable but that
do implement toString(). After a conversation w/ Joe it's been decided that
our Logging API will be to support the logging of arrays w/ objects that
implement a toString() function. The eagle-eyed may notice that this solution
differs from the one I put forth in the above PR. The reason being that the
original solution only supported the use case of having an array w/ top level
value objects and would not work as expected if a nested array is supplied with
an object that implements toString().

Motivation and Context

It's nice to have a logging api that works as expected.

Tests performed

All automated tests.

Checklist:

  • The pull request description is suitable for a Changelog entry
  • The milestone is set correctly on the pull request
  • The appropriate labels have been added to the pull request

We ran into a problem described in this PR:
ubccr#1490 After some research I found that the
root of the problem is this function json_encode'ing `$record` when the contents
of `$record` may contain objects that do not support `JsonSerializable` but that
do implement `toString()`. After a conversation w/ Joe it's been decided that
our Logging API will be to support the logging of arrays w/ objects that
implement a `toString()` function. The eagle-eyed may notice that this solution
differs from the one I put forth in the above PR. The reason being that the
original solution only supported the use case of having an array w/ top level
value objects and would not work as expected if a nested array is supplied with
an object that implements `toString()`.
@ryanrath ryanrath added bug Bugfixes Category:Infrastructure Internal infrastructure updates/changes labels Feb 8, 2021
@ryanrath ryanrath added this to the 9.5.0 milestone Feb 8, 2021
@jpwhite4
Copy link
Member

jpwhite4 commented Feb 9, 2021

Loks good. Please can you add a description of what this logger supports at the top of the file (so we don't forgret in future).

Something like:
If an object is passed to the logger then it will use the __toString() function to convert the object to a string.

@ryanrath
Copy link
Contributor Author

ryanrath commented Feb 9, 2021

@jpwhite4 Absolutely, I'll add that and push it up momentarily.

Per @jpwhite4, it's important that we document that our Logger supports logging
both strings and arrays, and if an array is provided that contains objects,
those objects will be converted to strings via the `__toString` function.
@ryanrath ryanrath merged commit 20a314e into ubccr:xdmod9.5 Feb 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugfixes Category:Infrastructure Internal infrastructure updates/changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants